赞
踩
[root@master ~]# ./1.test.sh hello,root,your UID is 0 hello,bin,your UID is 1 hello,daemon,your UID is 2 hello,adm,your UID is 3 hello,lp,your UID is 4 hello,sync,your UID is 5 hello,shutdown,your UID is 6 hello,halt,your UID is 7 hello,mail,your UID is 8 hello,operator,your UID is 11 hello,games,your UID is 12 hello,ftp,your UID is 14 hello,nobody,your UID is 65534 hello,dbus,your UID is 81 hello,systemd-coredump,your UID is 999 hello,systemd-resolve,your UID is 193 hello,tss,your UID is 59 hello,polkitd,your UID is 998 hello,unbound,your UID is 997 hello,sssd,your UID is 996 hello,sshd,your UID is 74 hello,mysql,your UID is 995 hello,apache,your UID is 994 hello,saslauth,your UID is 993 hello,zabbix,your UID is 992 当前有25用户 [root@master ~]# vi ./1.test.sh #!/bin/bash Fa=/etc/passwd sum=$(cat $Fa|wc -l) while read A;do username=$(echo $A|awk -F: '{print$1}') user_uid=$(echo $A|awk -F: '{print$3}') echo hello,$username,your UID is $user_uid done < $Fa echo "当前有$sum用户"
[root@master ~]# vi 2.test.sh #!/bin/bash #!/bin/bash echo "输入的第一个数为$1" echo "输入的第二个数为$2" echo "二数之和为$[$1+$2]" echo "二数之差为$[$1-$2]" echo "二数之积为$[$1*$2]" echo "二数之商为$[$1/$2]" [root@master ~]# chmod +x 2.test.sh [root@master ~]# ./2.test.sh 8 4 输入的第一个数为8 输入的第二个数为4 二数之和为12 二数之差为4 二数之积为32 二数之商为2
[root@master ~]# vi 3.test.sh
#!/bin/bash
mkdir /tmp/scripts
cd /tmp/scripts
cp -rf /etc/pam.d ./test
useradd redhat
chown -R redhat ./test
chmod -R o-rwx ./test
[root@master ~]# chmod +x 3.test.sh
[root@master ~]# ./3.test.sh
[root@master ~]# vi 4.test.sh
#!/bin/bash
date
mkdir /tmp/lstest
cd /tmp/lstest
mkdir a1d,b56e,6test
touch xy,x2y,732
ls [a,x,6]*
ls | egrep -i "^[a-z] [0-9]"
[root@master ~]# ./4.test.sh
Thu Sep 8 19:44:57 CST 2022
xy,x2y,732
a1d,b56e,6test:
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。