LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   teach me the better way (https://www.linuxquestions.org/questions/linux-newbie-8/teach-me-the-better-way-146310/)

slack66 02-15-2004 07:42 AM

teach me the better way
 
hi! i have a hundred file in my file server with an extension ex:
bak,autobak,backup of.......etc
and i want to delete it every day to save some space and i do it like this
find . -name *.bak -print -exec rm {} \;
find . -name *.autobak -print -exec rm {} \;
and so on:(
is there a better way to combine all bak,autobak,backup of in one command??? i try this but doest work correct me if iam wrong:)
the command is:
find . -name '*.[bak autobak backup of]' -print -exec rm {} \;

b0uncer 02-15-2004 08:14 AM

well, to remove all files which have three letters "bak" in it, just do

find . -name *.*bak* -print -exec rm {} \;

the problem is that it will remove ALL files with those three letters inside...so be aware ;)

druuna 02-15-2004 08:17 AM

Use the -o (OR) option

find . \( -name *bak -o -name *autobak -o -name backup \) -print -exec ls -l {} \;

Change ls -l to rm when you are sure this does what you want.

slack66 02-15-2004 10:55 PM

thks guy for your reply:)


All times are GMT -5. The time now is 07:04 PM.