#!/bin/bash
read -p "请输入一个文件名:" fileName
pos=`expr index $fileName \.`
type=`expr substr $fileName $((pos+1)) 2`if [ $type = sh ]
thenif [ -x $fileName ]thenbash $fileNameelsechmod a+x $fileNamefi
fi
read -p "请输入第一个文件名:" fileName1
read -p "请输入第二个文件名:" fileName2if [ -e $fileName1 -a -e $fileName2 ]
thenif [ $fileName1 -nt $fileName2 ]thenecho "${fileName1}更新"elseecho "${fileName2}更新"fi
elseecho "文件不存在,请输入存在的文件"fi
#!/bin/bash
read -p "请输入用户名:" username
a=(`grep $username -nw /etc/passwd`)
if [ ${#a[*]} -eq 0 ]
thensudo adduser $username
elseecho "用户已存在"
fi
#!/bin/bash
read -p "请输入成绩:" score
if [ $score -le 100 -a $score -gt 90 ]
thenecho "A"
elif [ $score -le 90 -a $score -gt 80 ]
thenecho "B"
elif [ $score -le 80 -a $score -gt 70 ]
thenecho "C"
elif [ $score -le 70 -a $score -gt 60 ]
thenecho "D"
elseecho "不合法输入"
fi
#!/bin/bashwhoami
username=`whoami`
id -u $username
pwd
echo `ls /etc/ | grep -i ^p | wc -l`