bash Shell Scripting Question
Mihai Donțu
mihai.dontu at gmail.com
Thu Sep 20 02:25:19 UTC 2012
On Wed, 19 Sep 2012 21:03:11 -0500 Martin McCormick wrote:
> #!/usr/local/bin/bash
> ls -LF |grep \/ >/tmp/files
> while read dirname; do
> cd $dirname
> #Do whatever commands to be repeated in each directory.
> done < /tmp/files
>
How about:
ls -LF | grep \/ | while read dirname; do
cd $dirname
# do stuff
done
or:
find . -maxdepth 1 -type d | while read dirname; do
cd $dirname
# do stuff
done
or even:
find . -maxdepth 1 -type d ! -name ".*" | while read dirname; do
cd $dirname
# do stuff
done
--
Mihai Donțu
More information about the freebsd-questions
mailing list