Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 23 Oct 2003 12:38:27 +0100
From:      Matthew Seaman <m.seaman@infracaninophile.co.uk>
To:        Scott Gerhardt <scott@g-it.ca>, FreeBSD <freebsd-questions@freebsd.org>
Subject:   Re: Fwd: Help: tar & find
Message-ID:  <20031023113827.GD39601@happy-idiot-talk.infracaninophile.co.uk>
In-Reply-To: <20031023113439.GC39601@happy-idiot-talk.infracaninophile.co.uk>
References:  <7F19C442-0513-11D8-8F40-000393801C60@g-it.ca> <20031023113439.GC39601@happy-idiot-talk.infracaninophile.co.uk>

next in thread | previous in thread | raw e-mail | index | archive | help

--W5WqUoFLvi1M7tJE
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Thu, Oct 23, 2003 at 12:34:40PM +0100, Matthew Seaman wrote:
> On Wed, Oct 22, 2003 at 10:43:50PM -0600, Scott Gerhardt wrote:
> >=20
> > I am having trouble combining the tar and find command.  I want to tar=
=20
> > and
> > delete all .bak,.Bak,.BAK files.
> >=20
> > I am using the following command but keep receiving errors.  The tar=20
> > command
> > appears to be receiving a truncated file/path (some of the time, but not
> > always), and trying to procecss the file as two files.
> >=20
> > Any help on this would be great.
> >=20
> > The script is as follows
> > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> > #! /bin/bash
> > set +x
> > TAR_DIR=3D/home/tarbackups;
> > FILES_DIR=3D/home/common;
> > tar --remove-files -cvzpf $TAR_DIR/bak_files_`date +%F`.tar.gz\
> >   `find $FILES_DIR -xdev -type f -iname "*.bak"`;
> > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> > The -xdev is to not desend into an external smb-mounted drive to a
> > subdirectory.
> >=20
> > I have also tried substituting single quotes for the double quotes=20
> > around the
> > *.bak
> >=20
> > Here is some error output returned:
> >=20
> > tar: jobs/ROOF: Cannot stat: No such file or directory
> > tar: LAYOUTS/RESIDENTIAL/FRASER/219: Cannot stat: No such file or=20
> > directory
> > tar: LEWIS: Cannot stat: No such file or directory
> > tar: CRES.bak: Cannot stat: No such file or directory
> > tar: /home/technical/nfsapc30-my_documents/1999: Cannot stat: No such=
=20
> > file or
> > directory
> > tar: jobs/ROOF: Cannot stat: No such file or directory
> > tar: LAYOUTS/RESIDENTIAL/FRASER/THODE: Cannot stat: No such file or=20
> > directory
> > tar: RES.bak: Cannot stat: No such file or directory
>=20
> The problem is that you have file/directory names like 'ROOF LAYOUTS'
> which contain spaces and possibly other filenames containing
> characters with syntactic significance to the shell.
>=20
> Try:
>=20
>     find $FILES_DIR -xdev -type f -iname "*.bak -print0 | \
>         xargs -0 tar --remove-files -cvzpf $TAR_DIR/bak_files_`date +%F`.=
tar.gz

Let's try that again, and fix the typo:

     find $FILES_DIR -xdev -type f -iname "*.bak" -print0 | \
         xargs -0 tar --remove-files -cvzpf $TAR_DIR/bak_files_`date +%F`.t=
ar.g

	Cheers,

	Matthew

--=20
Dr Matthew J Seaman MA, D.Phil.                       26 The Paddocks
                                                      Savill Way
PGP: http://www.infracaninophile.co.uk/pgpkey         Marlow
Tel: +44 1628 476614                                  Bucks., SL7 1TH UK

--W5WqUoFLvi1M7tJE
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (FreeBSD)

iD8DBQE/l72zdtESqEQa7a0RAic4AJ4/3rWKdM5VdiITwQwRDgZFucfLMACeMayO
9FbUKh2rNJeELcSTpXXZEEs=
=i43k
-----END PGP SIGNATURE-----

--W5WqUoFLvi1M7tJE--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20031023113827.GD39601>