Actually this kind of too much to ask I think.
But I want to remove all files matching the extension ".sh"(current folder only) which I can do with below command:
find . -maxdepth 1 -type f -name '*.sh' -exec rm {} +
But still I want to keep file "cron.sh" in the current folder unaffected.
How can I achieve this in single command line ?
rm -- !(cron).sh
– steeldriver Oct 20 '16 at 12:41rm !(cron.sh)
and couldn't find a way for it to not delete non-sh files. Nice one! Please post it as an answer. – terdon Oct 20 '16 at 14:12