标签:test 图片 com shel number raw gre passwd NPU
五只简简单单的shell脚本
#!/bin/bash
read -p ‘please enter a username:‘ username
#判断参数是否为空
if [ "$username" = "" ]; then
echo "please input a username"
exit 1
fi
#判断用户名是否存在
if grep $username /etc/passwd &> /dev/null; then
userid=$(id -u $username)
if [ $userid -lt 500 ];then
echo "$username is a admin user"
else
echo "$username is a normal user"
fi
else
echo "$username does not exist"
fi
#!/bin/bash
sum=0
for i in "$@"
do
sum=$[$sum+$i]
done
echo "$sum"
#!/bin/bash
sum=0
for i in "$@"
do
for line in $(cat $i)
do
sum=$[1+$sum]
done
done
echo "$sum"
#!/bin/bash
raw_dir="/home/moon/linux-test/test4-dir" #可修改绝对路径;
read -p ‘请输入需要移动到的路径:‘ raw_dir
mv ./*.c $raw_dir #移动文件
ls -S $raw_dir #按照文件大小对其进行排序输出
#!/bin/bash
max=$1
for x in $@
do
if [[ $x != *[!0-9]* ]];then
if [ $x -gt $max ];then
max=$x
fi
else
echo "‘$x‘ is not a number"
fi
done
echo "$max"
标签:test 图片 com shel number raw gre passwd NPU
原文地址:https://www.cnblogs.com/lightice/p/12681191.html