From owner-freebsd-questions@FreeBSD.ORG Thu Oct 23 04:35:17 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 2674216A4B3 for ; Thu, 23 Oct 2003 04:35:17 -0700 (PDT) Received: from smtp.infracaninophile.co.uk (ns0.infracaninophile.co.uk [81.2.69.218]) by mx1.FreeBSD.org (Postfix) with ESMTP id C30E443F3F for ; Thu, 23 Oct 2003 04:35:15 -0700 (PDT) (envelope-from m.seaman@infracaninophile.co.uk) Received: from happy-idiot-talk.infracaninophile.co.uk (localhost [127.0.0.1]) h9NBYeDK097002 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 23 Oct 2003 12:35:11 +0100 (BST) (envelope-from matthew@happy-idiot-talk.infracaninophile.co.uk) Received: (from matthew@localhost)id h9NBYe4j096937; Thu, 23 Oct 2003 12:34:40 +0100 (BST) (envelope-from matthew) Date: Thu, 23 Oct 2003 12:34:40 +0100 From: Matthew Seaman To: Scott Gerhardt Message-ID: <20031023113439.GC39601@happy-idiot-talk.infracaninophile.co.uk> Mail-Followup-To: Matthew Seaman , Scott Gerhardt , FreeBSD References: <7F19C442-0513-11D8-8F40-000393801C60@g-it.ca> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="XWOWbaMNXpFDWE00" Content-Disposition: inline In-Reply-To: <7F19C442-0513-11D8-8F40-000393801C60@g-it.ca> 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 cc: FreeBSD 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:35:17 -0000 --XWOWbaMNXpFDWE00 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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 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. Try: find $FILES_DIR -xdev -type f -iname "*.bak -print0 | \ xargs -0 tar --remove-files -cvzpf $TAR_DIR/bak_files_`date +%F`.ta= r.gz 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 --XWOWbaMNXpFDWE00 Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (FreeBSD) iD8DBQE/l7zPdtESqEQa7a0RAuaJAJ9Nwj3sF5RuEHe9GQ+4pB0zKXjtqQCfdhH6 3DBZm8NBTpeR1aeO39efF9g= =LgE8 -----END PGP SIGNATURE----- --XWOWbaMNXpFDWE00--