Find the answer to your Linux question:
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 ...
  1. #1
    Just 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

  2. #2
    Linux 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:

    Code:
    find /data/shippers -name "*.txt" -mtime 2 -type f | xargs tar czvf /dest_dir/$1.$(date +%y%m%d-%H%M%S).tgz
    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.

    Ref: Linux backup - Using find, xargs, and tar to create a huge archive | devdaily.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...