Re: Weird behavior with find command when tarring files

  • From: Andre Maasikas <amaasikas@xxxxxxxxx>
  • To: Amir.Hameed@xxxxxxxxx
  • Date: Fri, 19 Oct 2018 09:10:32 +0300

Hi,
see "man xargs"
xargs will execute the tar command with as much filenames as it thinks is
allowed on command line
(might be 128kb). If you have more files then it executes the command again
and the tar
will overwrite the first /tmp/test.tar etc...
See if tar has on option to to create/append to an existing tar file
or write the find output to a temp file and use tar option *--files-from*=
*FILE*

Andre

On Thu, Oct 18, 2018 at 11:57 PM Hameed, Amir <Amir.Hameed@xxxxxxxxx> wrote:

Hi,

I am using the *find* command to TAR up files that are older than 4 hours:



find . type f -mmin +239 | xargs tar -cvf /tmp/test.tar



The command tars up files and seems to finish fine. However, when I untar
and count the number of files against the count of files that should have
been captured (find . type f –mmin +239 | xargs ls –l | wc -l) there is a
huge difference and the files captured by tar were way less than the file
listed for the same time.



This is a strange behavior. What am I doing wrong (I am sure I am doing
something wrong)?





Thanks,

Amir





Other related posts: