On Tue, Aug 13, 2002 at 11:34:23AM +1000, John Clarke wrote:
> On Tue, Aug 13, 2002 at 11:26:25AM +1000, Hartono, Susanto wrote:
>
> > Something along this line should suffice..
> >
> > #!/bin/sh
> > for file in $HOME/*; do echo $file; done
>
> That'll only work on non-hidden files, unless the shell option dotglob
> is set (shopt -s dotglob, off by default). If you want all files, you
> can use:
>
> for file in `find . -type f -maxdepth 1`; do ...; done
These will not work when the number of files is large;
use something like the following instead. You could also add -a
to the ls options to get hidden files. This is also
more portable -- some finds do not understand maxdepth
ls -1 | while read f
do
.. do stuff with $f ...
done
PS. That's a _one_ as an option, not ell.
Shouldn't be necessary but these days you never know.
You might also need to turn off colour in your ls.
Also add a -d to ls's options if you're doing pattern
matching (as a precaution).
Matt
--
SLUG - Sydney Linux User's Group - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug