bash Shell Scripting Question

Martin McCormick martin at
Thu Sep 20 02:12:00 UTC 2012

	I just discovered a knowledge deficiency on my part that
I can't seem to resolve.

	If one writes a loop of the following form:

ls -LF |grep \/ >/tmp/files
while read dirname; do
cd $dirname
#Do whatever commands to be repeated in each directory.
done < /tmp/files

	This works quite well but it is shall we say sloppy
because it creates a file that then must be cleaned up and its
name needs to be made unique, etc.

	The standard output of the `ls -LF |grep \/` command
needs to look like a file and all should be well. I thought the
< redirection would pickup the standard output.

Thanks for ideas.

Martin McCormick

More information about the freebsd-questions mailing list