1. 程式人生 > >【shell腳本學習-2】

【shell腳本學習-2】

lc_all all read root 登錄用戶 tail 腳本 $1 用戶

#!/bin/bash - #echo do you have exetuate this project \n printf "please input your passwd" stty -echo read pass < /dev/tty printf "please agein input your passwd" read pass2 < /dev/tty stty echo #tr -s > 1.txt | sort > 2.txt #echo "1 6 8 1 4 9" > 1.txt | sort 1.txt | tail 1.txt #cat /dev/null #!/bin/bash #cat /bin/liupeng | grep a | wc #$1 #read $x #echo $x #set -x #跟蹤 #echo firset echo #set +x #取消跟蹤 #echo second echo #locale -a | grep "^L" #環境變量 #LC_ALL=da locale ck LC_TIME ######------------------------------grep+正則表達式-----------------------------# #who | grep -F u1 #判斷登錄用戶 #cat 1.txt | grep ^a | grep b$ #cat 1.txt | grep Aa.Aa #[Aa]d #含有Aa的字符 #cat 1.txt | grep ^Aa #以Aa開頭的字符 #cat 1.txt | grep Aa$ #以Aa結尾的字符 #cat 1.txt | grep [[:digit:]] | grep ^2 #匹配含有數字的行列 #cat 1.txt | grep [[:alnum:]] #cat 1.txt | grep \digit #cat 1.txt | grep ab*c #匹配含有一個a額字符 #cat 1.txt | grep [[:upper:]]\{3\}$ #匹配後三位為大寫的字符 #cat 1.txt | grep ab?c #匹配ab和abc #cat 1.txt | grep ab+c #----------------------------------sed+正則表達式_______________________________ #sed ‘s/:.*//‘ /root/1.txt #find /root -type d -print #mkdir -p /home/1 #sed ‘s;/home/1;/home/2;‘ # cat /root/1.txt | sed ‘s/a/B/g‘ #替換字符 #n #printf "hello world" #sed -n ‘/c/p‘ *.txt #sed -n ‘$p‘ "$1" #sed -n ‘2,5p‘ /root/1.txt #匹配打印的行數 echo "hello world" | sed ‘s/world/shell/‘ #替換指定的字符

【shell腳本學習-2】