Quote:
Originally Posted by Andy_Crowd
listing only directories:
for f in *;do if [[ -d $f ]]; then echo $f;fi; done;
|
is much easier to remember and faster to type
Quote:
Originally Posted by Andy_Crowd
listing only files:
for f in *;do if [[ -d $f ]]; then echo "" > /dev/null ;else echo $f ;fi; done;
|
That is grossly inefficient. Why would you test if it's a directory, and if so echo a newline to /dev/null and otherwise print the name? Why not just test if it's not a directory with [[ ! -d $f ]], or just directly test it's a file with [[ -f $f ]]?