Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 03-31-2005, 02:31 AM   #1
LQ Newbie
Registered: Oct 2004
Distribution: fedora core 3
Posts: 22

Rep: Reputation: 15
find: missing argument to `-exec'

this must be a very silly question, but after reading man find several times I haven't been able to figure out how to make it work...

I want to find the files in some folder that match some pattern and that were modified more than XX days ago, and delete them .

What I'm using is:
 find ~/sync/papers/ -name p*.* -mtime +5 -ls -exec rm{};
but I always get the error
find: missing argument to '-exec'

I've tried several approaches -rm{} [rm{}] {rm{}} (rm{}) --rm{} but the error persists

What am I doing wrong???
Is there any other way I can find and delete those files??

Thanks for the help!

Old 03-31-2005, 03:07 AM   #2
LQ Newbie
Registered: Mar 2005
Posts: 3

Rep: Reputation: 1
There should be some space between rm and {}

#find ~/sync/papers/ -name p*.* -mtime +5 -exec rm {} \;

And dont put -ls. If you want to use ls, you must use it with -exec.
1 members found this post helpful.
Old 03-31-2005, 04:15 AM   #3
Registered: Feb 2005
Location: Rio de Janerio
Distribution: suse 9.1, suse 9.2, redhat enterprise, ubuntu, kubuntu
Posts: 104

Rep: Reputation: 15
note the backslash before the semi-colon as well in pavodive's example
Old 03-31-2005, 10:02 PM   #4
LQ Newbie
Registered: Oct 2004
Distribution: fedora core 3
Posts: 22

Original Poster
Rep: Reputation: 15
Thank you guys! helped a lot!
Old 10-05-2009, 02:24 PM   #5
LQ Newbie
Registered: Aug 2007
Posts: 6

Rep: Reputation: 0
At last I know how to do -exec with find!
These forums will be a source of google-based knowledge for generations to come!


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Help sought with 'find -exec' drjones69 Linux - Software 2 04-27-2005 04:02 AM
find -exec question eantoranz Linux - General 1 06-26-2004 10:57 AM
find -exec cricbk Linux - Newbie 4 01-05-2004 07:03 PM
Kylix (delphi) missing exec command? RayJ Programming 2 09-24-2003 12:35 AM
how to find out if argument is number: bash kubicon Linux - Newbie 1 09-19-2003 04:12 PM

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

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