1. Change the suffix ". sh" suffix to ". Shell" under the/OPT directory (including subdirectories)
2. Renaming files A1, A2, A3 files in directories A, B and C to A4, A5, A6
3. How to change the AA string in the file to BB in the VI mode
1.
#!/bin/bashdir=/hanzhaofiles= ' find/hanzhao/-name ' *.sh ' for file in $filesdo # echo $file filename=${file%.*}# echo $fil ename MV $file ${filename}.shelldone
2.
#!/bin/bash file= ' ls/[abc]/a[123] ' for i in $file does num=${i##*a} let num1=num+3 # echo $ NUM1 # num2=${i%a*} # echo $num 2 mv $i ${i%a*}a$num1 done
3.
Open the file directly with VI, and then enter it directly in the re-read mode:%s#aa#bb#g
4 Back up the daily log
#!/bin/bashcp/opt/lampp/logs/access_log/opt/bak_access_log-' Date +%y%m%d%h%m '
>/opt/lampp/logs/access_log
5. Start Stop Lampp
#!/bin/bashstart=0pidnum= ' PS aux|grep "/opt/lampp/*" |wc-l ' echo ${pidnum}if [${pidnum}-gt 1]then echo ' lampp is start ' r Ead-p ' Do you wish to stop lampp? Y or N: ' yncase $yn in[yy]*) start=1;; [nn]*] exit; *) echo ' please answer Y or N ' exit; Esacelseecho ' lampp is stop,doing start ' read-p ' does you wish to start lampp? Y or N:
Shell script Review little exercise