#!/bin/bash-#echo do what exetuate this project \nprintf "Please input your passwd" Stty-echoread Pass </dev/ttyp rintf "Please agein input your passwd" read Pass2 </dev/ttystty 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+ Regular Expressions-----------------------------# #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 [[:d igit:]] | 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+ Regular expression _______________________________#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 ' "$" #sed-n ' 2,5p '/root/1.txt #匹配打印的行数echo "h Ello World "| Sed ' s/world/shell/' #替换指定的字符
Shell Scripting Learning-2