1,写一个脚本:
判断当前系统上是否有用户的默认shell 为bash;如果有,就显示有多少个这类用户;否则就显示没有这类用户;
[root@localhost mscripts]# cat lx1.sh
#!/bin/bash
grep "bashKaTeX parse error: Expected 'EOF', got '&' at position 15: " /etc/passwd &̲> /dev/null RVA…?
if [
R
V
A
L
U
E
−
e
q
0
]
;
t
h
e
n
N
1
=
g
r
e
p
"
b
a
s
h
RVALUE -eq 0 ]; then N1=grep "bash
RVALUE−eq0];thenN1=grep"bash" /etc/passwd | wc -l
echo “$N1 users’ shell is bash”
else
echo “no such the users.”
fi
shell练习
最新推荐文章于 2022-09-19 21:25:01 发布
该脚本用于检测当前系统上使用bash作为默认shell的用户数。通过grep命令过滤出/etc/passwd文件中包含bash的行,并通过wc-l计算这些行的数量。如果返回值为0,则说明没有用户使用bash作为默认shell;否则,将显示用户数量。
摘要由CSDN通过智能技术生成