代码:
#!/bin/bash
#if no arguments, then listing the current directory
#otherwise,listing each subdirectory
if test $# = 0; then
ls
else
for i in ./*; do
if test -d ${i}; then
ls -l $i
fi
done
fi
代码:
#!/bin/bash
#if no arguments, then listing the current directory
#otherwise,listing each subdirectory
if test $# = 0; then
ls
else
for i in ./*; do
if test -d ${i}; then
ls -ld $i
fi
done
fi
代码:
#!/bin/bash
#if no arguments, then listing the current directory
#otherwise,listing each subdirectory
if test $# = 0; then
ls
else
ls -l | grep ^d
fi
代码:
#!/bin/bash
#if no arguments, then listing the current directory
#otherwise,listing each subdirectory
if test $# = 0; then
ls
else
ls -l */
fi
代码:
#!/bin/bash
#if no arguments, then listing the current directory
#otherwise,listing each subdirectory
if test $# = 0; then
ls
else
ls -ld */
fi
参考
http://unix.stackexchange.com/questions/86722/how-do-i-loop-through-only-directories-in-bashhttp://stackoverflow.com/questions/14352290/listing-only-directories-using-ls-in-bash-an-examination