From owner-freebsd-questions@FreeBSD.ORG Tue Jun 16 16:58:49 2009 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5614910656C5 for ; Tue, 16 Jun 2009 16:58:49 +0000 (UTC) (envelope-from m.seaman@infracaninophile.co.uk) Received: from smtp.infracaninophile.co.uk (gate6.infracaninophile.co.uk [IPv6:2001:8b0:151:1::1]) by mx1.freebsd.org (Postfix) with ESMTP id CD7188FC21 for ; Tue, 16 Jun 2009 16:58:48 +0000 (UTC) (envelope-from m.seaman@infracaninophile.co.uk) Received: from happy-idiot-talk.infracaninophile.co.uk (localhost [IPv6:::1]) (authenticated bits=0) by smtp.infracaninophile.co.uk (8.14.3/8.14.3) with ESMTP id n5GGwgZc058584; Tue, 16 Jun 2009 17:58:43 +0100 (BST) (envelope-from m.seaman@infracaninophile.co.uk) X-DKIM: Sendmail DKIM Filter v2.8.3 smtp.infracaninophile.co.uk n5GGwgZc058584 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=infracaninophile.co.uk; s=200708; t=1245171523; bh=7EOw2xQbnIa440Gf5OxTKkslO1Wf2F+Wml1dfjLtjDk=; h=Message-ID:Date:From:MIME-Version:To:CC:Subject:References: In-Reply-To:Content-Type:Cc:Content-Type:Date:From:In-Reply-To: Message-ID:Mime-Version:References:To; z=Message-ID:=20<4A37CF3C.5000808@infracaninophile.co.uk>|Date:=20T ue,=2016=20Jun=202009=2017:58:36=20+0100|From:=20Matthew=20Seaman= 20|Organization:=20Infracaninophi le|User-Agent:=20Thunderbird=202.0.0.21=20(X11/20090420)|MIME-Vers ion:=201.0|To:=20Carmel=20NY=20|CC:=20FreeB SD=20Questions=20|Subject:=20Re:=20 Problem=20with=20bash=20script|References:=20|In-Reply-To:=20|X-Enigmail-Version:=200.95.6|Content-Type:=2 0multipart/signed=3B=20micalg=3Dpgp-sha256=3B=0D=0A=20protocol=3D" application/pgp-signature"=3B=0D=0A=20boundary=3D"------------enig 3BD5A5F4D1015FA78118F8E8"; b=UrbxAKc3gXBAhPNGhy8kIS5EeFfFbk/kgQvJo8dNKGOmKa+/IYDUoo4YFulu+6kuO H6BDhM5J8yeuWfNOr642VDjwe4MPiEzUiaFMzKPblCGi1BV2F5gO3tM3CL7xAfviH+ 3oh1C6bRJfnU1go10jGK1grLWFczRlLy+4DMhaAU= X-Authentication-Warning: happy-idiot-talk.infracaninophile.co.uk: Host localhost [IPv6:::1] claimed to be happy-idiot-talk.infracaninophile.co.uk Message-ID: <4A37CF3C.5000808@infracaninophile.co.uk> Date: Tue, 16 Jun 2009 17:58:36 +0100 From: Matthew Seaman Organization: Infracaninophile User-Agent: Thunderbird 2.0.0.21 (X11/20090420) MIME-Version: 1.0 To: Carmel NY References: In-Reply-To: X-Enigmail-Version: 0.95.6 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enig3BD5A5F4D1015FA78118F8E8" X-Virus-Scanned: clamav-milter 0.95.2 at happy-idiot-talk.infracaninophile.co.uk X-Virus-Status: Clean X-Spam-Status: No, score=-3.0 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VERIFIED,NO_RELAYS autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on happy-idiot-talk.infracaninophile.co.uk Cc: FreeBSD Questions Subject: Re: Problem with bash script X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Jun 2009 16:58:49 -0000 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig3BD5A5F4D1015FA78118F8E8 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Carmel NY wrote: > I am attempting to write a simple Bash script that will find all the > '*.pem' files in a directory structure and move them to another > directory. It seems to work until I get to the copy part where it fails= =2E >=20 > My scripting skills are not that good. Perhaps someone could tell me > what I am doing wrong. >=20 > This is the script: >=20 > #! /usr/bin/env bash >=20 > # Save the field separator > oIFS=3D$IFS >=20 > # Set it to line breaks > IFS=3D$'\n' >=20 > for i in $(find ./ -name "*.pem" -print); do >=20 > # Get the basename > BN=3D$(basename $i) >=20 > # copy the file to another directory using the base name > cp $i /usr/home/tmp/$BN >=20 > done >=20 > # Reset the IFS variable > IFS=3D$oIFS >=20 > exit That's a one-liner: % find . -depth -name '*.pem' -print0 | cpio -0pdmu /usr/home/tmp Actually, that just /copies/ all of the *.pem files to the other director= y tree, so if you want to remove the original files, you'ld also need to do= : % find . -name '*.pem' -delete=20 once you're sure everything has copied across OK, and with the proviso that '.' is neither a parent or child of /usr/home/tmp Cheers, Matthew --=20 Dr Matthew J Seaman MA, D.Phil. 7 Priory Courtyard Flat 3 PGP: http://www.infracaninophile.co.uk/pgpkey Ramsgate Kent, CT11 9PW --------------enig3BD5A5F4D1015FA78118F8E8 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.11 (FreeBSD) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEAREIAAYFAko3z0IACgkQ8Mjk52CukIyb1QCfbWLKF5gh4ogdyVjDJeWLLNVm 6eQAnRvLzM2UYnR4T7kxFMeCT8i+nuf4 =TYen -----END PGP SIGNATURE----- --------------enig3BD5A5F4D1015FA78118F8E8--