本人是初学shell脚本编程,望每行都能解释下。
1.
#!/bin/bash
for filename in $(find $1)
do
if [ -d $filename ]
then
printf "%8s %s\n" dir $filename
else
ls -lh $filename | cut -d " " -f5,8 \
| awk '{printf "%8s %s\n", $1, $2}'
fi
done
2.
#!/bin/bash
for emptydir in \
$(find $1 -type d -a -user $USER \
-a -empty -a ! -path '*/.*' 2>/dev/null); do
echo -n "目录 $emptydir 需要删除吗?[y/n]:"
read answer
answer=$(echo $answer | tr 'A-Z' 'a-z')
if [ $answer == y ];then
rmdir $emptydir
fi
done
谢谢哈!
vikenfeng 于 2011-12-14 16:40:35发表:
路过