Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 05 Aug 2009 08:36:31 +0100
From:      Matthew Seaman <m.seaman@infracaninophile.co.uk>
To:        Jay Hall <jhall@socket.net>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: find question
Message-ID:  <4A79367F.8000003@infracaninophile.co.uk>
In-Reply-To: <42D44C8E-1E22-426C-A9AA-0FBF2A52188A@socket.net>
References:  <42D44C8E-1E22-426C-A9AA-0FBF2A52188A@socket.net>

next in thread | previous in thread | raw e-mail | index | archive | help
This is an OpenPGP/MIME signed message (RFC 2440 and 3156)
--------------enigB6D269A3F869933A679D3F0A
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Jay Hall wrote:
> I am sure this is something I am doing that is obviously wrong, but I
> cannot figure it out.
>=20
> I am reading a list of directories from a file, and then listing all of=

> the files in the directory to a file.
>=20
> Here is the code.
>=20
> #!/usr/local/bin/bash
>         cat ${FILELIST} | while read LINE
>         do
>                 echo ${LINE}
>                 `find ${LINE} -type f >> ${TMPFILE}`
>         done
>=20
> Here is the output.
> /usr/home/windowsaccess
>=20
> find: illegal option -- t
> find: illegal option -- y
> find: illegal option -- p
> find: illegal option -- e
> find: f: No such file or directory
>=20
> Any suggestions would be greatly appreciated.
>=20

Try this as:

    for line in $( cat $FILELIST ) ; do
	echo $line
	find $line -type f >> $TMPFILE
    done

*assuming that none of the directory names in $FILELIST contain spaces*

This will split the contents of the file based on the current setting of =

$IFS (input field separator, which usually matches any whitespace).  You =
can
do some interesting tricks by redefining IFS...

Not sure what you're trying to achieve by the backticks around your find =
line
-- that actually says "take the output of this command and try and run it=
 as
a command line" which is probably not what you want.

	Cheers,

	Matthew

--=20
Dr Matthew J Seaman MA, D.Phil.                       Flat 3
                                                      7 Priory Courtyard
PGP: http://www.infracaninophile.co.uk/pgpkey         Ramsgate
                                                      Kent, CT11 9PW, UK


--------------enigB6D269A3F869933A679D3F0A
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.12 (FreeBSD)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkp5NoYACgkQ3jDkPpsZ+VY3sgCfSK/pNwO8czOD+KsR8aeDUSvB
0OEAnjonfVQSM6682PMiycUVoOWzIynk
=ZRKu
-----END PGP SIGNATURE-----

--------------enigB6D269A3F869933A679D3F0A--



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