From owner-freebsd-questions@FreeBSD.ORG Thu Oct 23 04:39:04 2003 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A183D16A4B3 for ; Thu, 23 Oct 2003 04:39:04 -0700 (PDT) Received: from smtp.infracaninophile.co.uk (smtp.infracaninophile.co.uk [81.2.69.218]) by mx1.FreeBSD.org (Postfix) with ESMTP id 321FD43FBD for ; Thu, 23 Oct 2003 04:39:03 -0700 (PDT) (envelope-from m.seaman@infracaninophile.co.uk) Received: from happy-idiot-talk.infracaninophile.co.uk (localhost [127.0.0.1]) h9NBcRDK011611 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 23 Oct 2003 12:38:57 +0100 (BST) (envelope-from matthew@happy-idiot-talk.infracaninophile.co.uk) Received: (from matthew@localhost)id h9NBcR92011610; Thu, 23 Oct 2003 12:38:27 +0100 (BST) (envelope-from matthew) Date: Thu, 23 Oct 2003 12:38:27 +0100 From: Matthew Seaman To: Scott Gerhardt , FreeBSD Message-ID: <20031023113827.GD39601@happy-idiot-talk.infracaninophile.co.uk> Mail-Followup-To: Matthew Seaman , Scott Gerhardt , FreeBSD References: <7F19C442-0513-11D8-8F40-000393801C60@g-it.ca> <20031023113439.GC39601@happy-idiot-talk.infracaninophile.co.uk> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="W5WqUoFLvi1M7tJE" Content-Disposition: inline In-Reply-To: <20031023113439.GC39601@happy-idiot-talk.infracaninophile.co.uk> User-Agent: Mutt/1.5.4i X-Spam-Status: No, hits=-4.9 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=2.60 X-Spam-Checker-Version: SpamAssassin 2.60 (1.212-2003-09-23-exp) on happy-idiot-talk.infracaninophile.co.uk Subject: Re: Fwd: Help: tar & find X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Oct 2003 11:39:04 -0000 --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--