Date: Tue, 16 Jun 2009 14:33:37 +0000 From: Paul Schmehl <pauls@utdallas.edu> To: Carmel NY <carmel_ny@hotmail.com>, FreeBSD Questions <freebsd-questions@freebsd.org> Subject: Re: Problem with bash script Message-ID: <7F04C88B7C6A39C7E1B6F366@utd65257.utdallas.edu> In-Reply-To: <BLU0-SMTP586D9F12148D0B6683B635933F0@phx.gbl> References: <BLU0-SMTP586D9F12148D0B6683B635933F0@phx.gbl>
next in thread | previous in thread | raw e-mail | index | archive | help
--==========1E08F14CBC8E2C2B4973========== Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline --On Tuesday, June 16, 2009 08:09:09 -0500 Carmel NY <carmel_ny@hotmail.com>=20 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. > > My scripting skills are not that good. Perhaps someone could tell me > what I am doing wrong. > > This is the script: > ># ! /usr/bin/env bash > ># Save the field separator > oIFS=3D$IFS > ># Set it to line breaks > IFS=3D$'\n' > > for i in $(find ./ -name "*.pem" -print); do > ># Get the basename > BN=3D$(basename $i) > ># copy the file to another directory using the base name > cp $i /usr/home/tmp/$BN > > done > ># Reset the IFS variable > IFS=3D$oIFS > > exit > When I write scripts, I test them on the commandline to see if they're doing=20 what I think they're doing. I don't get the $(find ....) construction. You're = invoking find from within a for loop to return a value. Use backticks. This works. for i in `find ./ -name "*.pem" -print` do foo bar done --=20 Paul Schmehl (pauls@utdallas.edu) Senior Information Security Analyst The University of Texas at Dallas http://www.utdallas.edu/ir/security/ --==========1E08F14CBC8E2C2B4973==========--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?7F04C88B7C6A39C7E1B6F366>