【shell脚本学习-2】

#!/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/' #替换指定的字符

posted on 2018-08-23 21:17  activecode  阅读(153)  评论(0编辑  收藏  举报

导航