1. Grammatical structure
2. Case studies
2.1 Batch Decompression
#!/bin/bashcd/root/test/ls *.tar.gz > Ls.logls *.tgz >> ls.logfor i in $ (cat ls.log) do tar-zxf $i &A mp;>/dev/null donerm-rf ls.log~ ~ ~ "for2.sh" 11L, 145C
2.2 Adding a specified number of users in bulk
#!/bin/bashread-p "Input username:"-t-nameread-p "input Total No. of users: "-t-numread-p" Input password for users: "-t-pswif [! -Z "$name"-A! -Z "$num"-A! -Z "$PSW"] then y=$ (echo $num | sed ' s/[0-9]//g ') if [-Z ' $y] Then For ((i=1;i<= $num; i=i+1)) Do/usr/sbin/useradd $name $ I &>/dev/null echo $pass | /USR/BIN/PASSWD--stdin $name $i &>/dev/null done fifi~ ~ ~ "For4.sh" 19L, 422C
2.3 Delete all regular users in bulk
#!/bin/bashusr=$ (cat/etc/passwd | grep/bin/bash | grep-v root | cut-d ":"-f1) for I in $usr do userdel-r $i
done~ ~ ~ "for5.sh" 9L, 127C
Shell Programming for Loop