11-23-06 12:33 PM
On 22.11.2006, Michael Tosch <eedmit@NO.eed.SPAM.ericsson.PLS.se> wrote:
> Chris F.A. Johnson wrote:
[vbcol=seagreen]
>
> In the Bourne shell (/bin/sh),
> you can even have a recursive routine,
> that will find/list the entire directory tree:
>
> #!/bin/sh
> readdir(){
> for file in "$1"/*
> do
> if [ -f "$file" ]; then
> echo "$file (file)"
> elif [ -d "$file" ]; then
> echo "$file (directory)"
> readdir "$file"
> fi
> done
> }
> readdir "."
I would use find (GNU find, actually):
find . -type f -printf '%p (file)\n' -o -type d -printf '%p (directory)\n'
--
<Kosma> Niektórzy lubi± dozziego...
<Kosma> Oczywi¶cie szanujemy ich.
Stanislaw Klekot
[ Post a follow-up to this message ]
|