find and delete in linux
how can i find all files that have "!" in the beginning and delete them all from a particular directory like /home/sam
You can either wrap the filename in single quotes like: rm '!2005-somefile.php'
or, escape the ! with: rm \!2005-somefile.php
To find all of these files that are in or under /home/sam you can use something like:
find /home/sam -name '!*' -exec ls -l {} \; # This will display each file - no delete
find /home/sam -name '!*' -exec rm -i {} \; # This will delete each file after you confirm the delete
find /home/sam -name '!*' -exec rm -f {} \; # This will delete each file without confirmation
0 Comments:
Post a Comment
<< Home