#!/bin/bash
p=`ls ~/ -l | grep "^-" | wc -l`
q=`ls ~/ -l | grep "^d" | wc -l`
echo "普通文件个数:$p"
echo "目录文件个数:$q"
#!/bin/bash
read file
pos=`expr index $file \.`
str=`expr substr $file $((pos+1)) 2`
if [ $str == "sh" ]
then
if [ -x $file ]
then
echo "$file是脚本文件"
bash $file
else
chmod u+x $file
fi
else
echo "$file不是脚本文件"
fi
#!/bin/bash
read file1 file2
if [ $file1 -nt $file2 ]
then
echo "file1比file2更新"
elif [ $file1 -ot $file2 ]
then
echo "file2比file1更新"
fi
#!/bin/bash
read user
name=`grep -q $user /etc/passwd`
if [ $? -eq 0 ]
then
echo "$user用户存在"
else
echo "$user用户不存在"
sudo adduser $user
fi
#!/bin/bash
read score
if [ $score -gt 90 -a $score -le 100 ]
then
echo "A等级"
elif [ $score -gt 80 -a $score -le 90 ]
then
echo "B等级"
elif [ $score -gt 70 -a $score -le 80 ]
then
echo "C等级"
elif [ $score -gt 60 -a $score -le 70 ]
then
echo "D等级"
elif [ $score -gt 0 -a $score -le 60 ]
then
echo "不合格"
else
echo "输入的成绩不合法,请重新输入"
fi
#!/bin/bash
name=`whoami`
arr=( $name `id -u $name` `echo $PATH`)
echo ${arr[*]}
#!/bin/bash
num=`ls -d /etc/[Pp]* | wc -l`
echo $num