Chinaunix首页 | 论坛 | 博客
  • 博客访问: 20277
  • 博文数量: 14
  • 博客积分: 433
  • 博客等级: 下士
  • 技术积分: 145
  • 用 户 组: 普通用户
  • 注册时间: 2012-02-16 23:07
文章分类

全部博文(14)

文章存档

2012年(14)

最近访客

分类: Python/Ruby

2012-06-28 13:01:14


点击(此处)折叠或打开

  1. #!/bin/bash
  2. if test $# -ne 1
  3.     then
  4.         echo "Usage: $0: you have to contain an argument"
  5.         exit 1
  6. fi
  7. if test -f "$1"
  8.     then
  9.         FileName="$1"
  10.         rm $FileName
  11. fi
  12. if test -d "$1"
  13.     then
  14.         DirectoryName="$1"
  15.         rm -rf $DirectoryName
  16. fi
  17. exit 0

点击(此处)折叠或打开

  1. #!/bin/bash
  2. if test $# -ne 1 #if the argument number is not 1
  3.    then
  4.     echo "Usage: $0 ordinary_file" # output usage
  5.     exit 1
  6. fi
  7. if test -f "$1"
  8.    then
  9.     FileName="$1" #file name
  10.     set $(ls -il $FileName) #set the output of the cmd as environment variable
  11.     #set `ls -il $FileName`
  12.     FileOwner="$4" #file owner
  13.     date1="$7" # year, moth, day
  14.     date2="$8" #time
  15.     echo "The owner of $FileName is: $FileOwner"
  16.     echo "The last modified date is: $date1 $date2"
  17.     exit 0
  18. fi
  19. echo "$0: argument must be an ordinary file" #output usage if the argument is not an ordinary file
  20. exit 1
shell 读文件!!!
很好的博文!!!

首次用shell,真心不习惯!

#!/bin/bash

echo "Welcome to Homework Management System"
echo "Enter Your Choice"
echo "1-administrator    2-teacher    3-student"

read choice #user's choice

if [ $choice -eq "1" ]
then
echo "enter username:"
read username #read username 
echo "enter password:"
read password #read password
flag=0
more admin | while read uname passwd
do
if [ $uname = $username -a $passwd = $password ]
then
flag=1 #if sucessfully login, set flag to be 1
break
fi
done #end while

if [ $flag = 1 ]
then
echo "username or password error"
exit 1
else
echo "succeed"
#
fi
fi

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

上一篇:Skiplist cooooooooooooooooooool!

下一篇:poj_3176

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