find question
Matthew Seaman
m.seaman at infracaninophile.co.uk
Wed Aug 5 07:36:52 UTC 2009
Jay Hall wrote:
> I am sure this is something I am doing that is obviously wrong, but I
> cannot figure it out.
>
> I am reading a list of directories from a file, and then listing all of
> the files in the directory to a file.
>
> Here is the code.
>
> #!/usr/local/bin/bash
> cat ${FILELIST} | while read LINE
> do
> echo ${LINE}
> `find ${LINE} -type f >> ${TMPFILE}`
> done
>
> Here is the output.
> /usr/home/windowsaccess
>
> find: illegal option -- t
> find: illegal option -- y
> find: illegal option -- p
> find: illegal option -- e
> find: f: No such file or directory
>
> Any suggestions would be greatly appreciated.
>
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
--
Dr Matthew J Seaman MA, D.Phil. Flat 3
7 Priory Courtyard
PGP: http://www.infracaninophile.co.uk/pgpkey Ramsgate
Kent, CT11 9PW, UK
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 259 bytes
Desc: OpenPGP digital signature
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20090805/a45edfb8/signature.pgp
More information about the freebsd-questions
mailing list