Chinaunix首页 | 论坛 | 博客
  • 博客访问: 319107
  • 博文数量: 75
  • 博客积分: 2137
  • 博客等级: 大尉
  • 技术积分: 1190
  • 用 户 组: 普通用户
  • 注册时间: 2006-02-23 00:02
文章分类

全部博文(75)

文章存档

2011年(3)

2009年(49)

2008年(23)

我的朋友

分类: 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

 

 

 

**************************

已知道问题,不能对~目录识别,另外如果输入中有空格也无法识别。

只统计目录,可执行文件,和连接文件,其他都不计算。

阅读(1529) | 评论(0) | 转发(0) |
0

上一篇:生存说

下一篇:umask释义

给主人留下些什么吧!~~