分类: BSD
2008-12-31 10:00:47
#!/bin/ksh
# This is my test shell (ksh)
# name file : sort directory and executable file and link file
clear
print " "
print " "
print " **************************************************"
print " sort directory and executable file and link file"
print " **************************************************"
print " "
print " "
print " "
print " Hi $(who i am | cut -c 1-6), nice to see you ! "
print " Your present information . "
print " OS : $(uname -s) IP : $(who i am | cut -c 35-48)"
print " Machine : $(uname -p)"
print " Currently work directory : $(pwd) "
print " "
while (true)
do
print " "
print -n " Please enter sort path (enter x logout!) :";
read path1 ;
print " Your enter path :" $path1;
print " "
case $path1 in
x)
print " Thank you test this ksh Script ! "
print " Good luck ! "
exit 1 ;;
~)
if ( $LOGNAME == root)
then
print " Directory :" $(ls -l /root | grep -c 'd[r-][w-][x-]')
print " Exexutable file :" $(ls -l /root |grep -c '[d-][r-][w-]x')
print " Link file : " $(ls -l /root | grep -c 'l[r-][w-][x-]')
else
print " Directory :" $(ls -l /home/$LOGNAME | grep -c 'd[r-][w-][x-]')
print " Exexutable file :" $(ls -l /home/$LOGNAME |grep -c '[d-][r-][w-]x')
print " Link file : " $(ls -l /home/$LOGNAME | grep -c 'l[r-][w-][x-]')
fi
next ;;
*)
if [ ! -d $path1 ]
then
print " Youre enter path no availability !"
elif
then
print " Directory :" $(ls -l $path1 | grep -c 'd[r-][w-][x-]')
print " Exexutable file :" $(ls -l $path1 |grep -c '[d-][r-][w-]x')
print " Link file : " $(ls -l $path1 | grep -c 'l[r-][w-][x-]')
fi;;
esac
done
**************************
已知道问题,不能对~目录识别,另外如果输入中有空格也无法识别。
只统计目录,可执行文件,和连接文件,其他都不计算。