|
ÂŴ˪L http://www.lslnet.com 2006¦~8¤ë08¤é 13:08
¦p¦ó¥Î Shell ¸}¥»½s¼g»¼Âkµ{§Ç
•J•JUNIX Shell ¸}¥»Ãþ¦ü DOS ªº§å³B²z©R¥O¡A¦ý¤ñ¸û°_¨Ó UNIX Shell ªº¥\¯à§ó±j¤j¡A¦b¬Y¨Ç¤è±¡AShell ¬Æ¦Ü¶W¹L¤F¤@¨Ç°ª¯Å»y¨¥¡C
•J•J¤UÃ䪺 Shell ¸}¥»ºt¥Ü¤F¦p¦ó¥Î Shell ¸}¥»½s¼g»¼Âkµ{§Ç¡C
•J•J¹B¦æ«e¥ý°õ¦æ¤Uz·Ç³Æ©R¥O¡G
•J•Jln tree.sh /usr/bin/tree
•J•Jln tree.sh /usr/bin/wtree
•J•Jln tree.sh /usr/bin/dtree
•J•Jrm tree.sh
# tree.sh
# Depth first Directory list
dtree() {
PWD=`pwd|sed 's/\/\$//`
for d in $*
do
echo "${PWD}/$d"
[ -d "$d" -a -x "$d" ] && {
cd "$d"
dtree *
cd ..
PWD=`pwd|sed 's/\/\$//` # restore PWD
}
done
}
# Depth first Directory list
wtree() {
PWD=`pwd|sed 's/\/\$//`
for d in $*
do
echo ${PWD}/$d
done
for d in $*
do
[ -d "$d" -a -x "$d" ] && {
cd $d
wtree *
cd ..
}
done
}
# Directory list
tree() {
PWD=`pwd|sed 's/\/\$//`
for d in $*
do
echo ${PWD}/$d
done
}
# main
TREE=`basename $0`
if [ "$1" ]
then DIR="$1"
else DIR="."
fi
if cd $DIR
then $TREE *
else echo "$0: Directory $1 read fail."
fi
# (End)
[b][/b] :em11: :em11: :em11: :em11: :em11: :em11: |
| |