Results 1 to 2 of 2
I was wondering if anyone could explain what is wrong with this. I keep getting a missing argument to `-exec'
find /data/shippers -name "*.txt" -mtime 2 -type f -exec tar ...
- 11-16-2009 #1Just Joined!
- Join Date
- Nov 2009
- Posts
- 1
Missing argument to -exec
I was wondering if anyone could explain what is wrong with this. I keep getting a missing argument to `-exec'
find /data/shippers -name "*.txt" -mtime 2 -type f -exec tar czvf $1.$(date +%y%m%d-%H%M%S).tar /data/shippers/archive
What I am trying to do is find all the txt files that are 2 to 3 days old and archiving them into the archive folder. Any advice or help would be greatly appreciated.
Thank You in advance
Winston
- 11-17-2009 #2Linux User
- Join Date
- May 2008
- Location
- NYC, moved from KS & MO
- Posts
- 251
Using -exe like what you did will never get what you intended. Try to use xargs instead:
Of course you have to make sure you pass argument to $1. The destination folder for the tar archive should be anywhere other than /data/shippers, otherwise your tar file will keep rolling until you run out of space.Code:find /data/shippers -name "*.txt" -mtime 2 -type f | xargs tar czvf /dest_dir/$1.$(date +%y%m%d-%H%M%S).tgz
Ref: Linux backup - Using find, xargs, and tar to create a huge archive | devdaily.com


Reply With Quote