I have a directory which contains hidden files and by that I mean, not just the files whose name starts with .
but also the files whose name contains ~
character at the end like somefile.txt~
.
I want to delete only those files (the remaining files need to be unaffected) in an efficient way.
How I can achieve that with a single command ?
Ubuntu 14.04 Trusty Tahr.
rm $(ls -a | grep -e "^\.[a-zA-Z0-9_ ].*" -e ".*~")
Perhaps a bit wordy, but is does the job without deleting anything it should not. – SE - stop firing the good guys Jun 24 '16 at 11:56