LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-15-2004, 07:42 AM   #1
slack66
Member
 
Registered: Jul 2003
Location: manila
Distribution: slackware 8 to 9
Posts: 199

Rep: Reputation: 30
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 {} \;
 
Old 02-15-2004, 08:14 AM   #2
b0uncer
LQ Guru
 
Registered: Aug 2003
Distribution: CentOS, OS X
Posts: 5,131

Rep: Reputation: Disabled
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
 
Old 02-15-2004, 08:17 AM   #3
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
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.

Last edited by druuna; 02-15-2004 at 08:18 AM.
 
Old 02-15-2004, 10:55 PM   #4
slack66
Member
 
Registered: Jul 2003
Location: manila
Distribution: slackware 8 to 9
Posts: 199

Original Poster
Rep: Reputation: 30
thks guy for your reply
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Please teach me how to use getc(stdin) Eileen Programming 12 12-20-2004 12:34 AM
teach me how to get online demmylls Linux - Networking 4 11-22-2004 04:31 AM
where is some material to teach linux? eantoranz Linux - General 3 11-02-2004 12:20 PM
Teach me Alucard9 Linux - Newbie 5 12-07-2003 09:16 AM
teach me to fish bandofmercy Linux - General 6 04-10-2003 01:40 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:50 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration