S20.shell脚本每日一练
shell 脚本 每日
2023-09-14 09:15:22 时间
39.查看/sbin/nologin的shell类型的用户名和UID
[root@rocky8 ~]# vim while_read_passwd.sh
#!/bin/bash
#
#**********************************************************************************************
#Author: Raymond
#QQ: 88563128
#Date: 2021-10-20
#FileName: while_read_passwd.sh
#URL: raymond.blog.csdn.net
#Description: The test script
#Copyright (C): 2021 All rights reserved
#*********************************************************************************************
while read line ;do
if [[ "$line" =~ /sbin/nologin$ ]] ;then
echo $line | cut -d: -f1,3
fi
done < /etc/passwd
[root@rocky8 ~]# bash while_read_passwd.sh
bin:1
daemon:2
adm:3
lp:4
mail:8
operator:11
games:12
ftp:14
nobody:65534
dbus:81
systemd-coredump:999
systemd-resolve:193
tss:59
polkitd:998
unbound:997
sssd:996
sshd:74
40.实现进度条功能
[root@rocky8 ~]# vim progress_chart.sh
#!/bin/bash
#
#**********************************************************************************************
#Author: Raymond
#QQ: 88563128
#Date: 2021-10-21
#FileName: progress_chart.sh
#URL: raymond.blog.csdn.net
#Description: The test script
#Copyright (C): 2021 All rights reserved
#*********************************************************************************************
function print_chars(){
# 传入的第一个参数指定要打印的字符串
local char="$1"
# 传入的第二个参数指定要打印多少次指定的字符串
local number="$2"
local c
for ((c = 0; c < number; ++c)); do
printf "$char"
done
}
COLOR=32
declare -i end=50
for ((i = 1; i <= end; ++i)); do
printf "\e[1;${COLOR}m\e[80D["
print_chars "#" $i
print_chars " " $((end - i))
printf "] %3d%%\e[0m" $((i * 2))
sleep 0.1s
done
echo
[root@rocky8 ~]# bash progress_chart.sh
[##################################################] 100%
相关文章
- linux shell 脚本攻略学习16--wc命令详解,tree命令详解
- Linux Shell脚本自动化编程实战- shell函数
- Linux Shell脚本自动化编程实战- shell并发
- 获取shell脚本自身所在目录的Shell脚本分享
- linux shell 脚本攻略学习18--grep命令详解
- linux shell 脚本攻略学习13--file命令详解,diff命令详解
- shell脚本中cat EOF1的意思
- Shell脚本攻略学习九之tr命令
- shell脚本循环读出文件每一行
- S28.shell脚本每日一练
- S26.shell脚本每日一练
- S19.shell脚本每日一练
- S18.shell脚本每日一练
- S17.shell脚本每日一练
- S16.shell脚本每日一练
- S14.shell脚本每日一练
- shell脚本并发控制详解
- shell脚本-for循环语句详解