Re: Weird behavior with find command when tarring files
Date: Thu, 25 Oct 2018 23:48:30 -0700
Message-ID: <CAORjz=OskPFAVnRchWBrgnNw7E-Ftk5GK7mo42TZa8L_qUBmkw_at_mail.gmail.com>
In addition to the other fine comments, you should get in the habit of dealing with filenames that have spaces.
It seems impossible to anymore to avoid this, as you don't always have control over it.
Here's how: use the '-print0' option for find, and the '-0' option for xargs.
find . type f -mmin +239 -print0 | xargs -0 tar -cvf /tmp/test.tar
Jared Still
Certifiable Oracle DBA and Part Time Perl Evangelist
Principal Consultant at Pythian
Pythian Blog http://www.pythian.com/blog/author/still/
Github: https://github.com/jkstill
On Thu, Oct 18, 2018 at 1:58 PM Hameed, Amir <Amir.Hameed_at_xerox.com> 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
>
>
>
>
>
-- http://www.freelists.org/webpage/oracle-lReceived on Fri Oct 26 2018 - 08:48:30 CEST