Linux and Unix Shell -- 基础概念

来源:互联网 发布:php项目技术文档 编辑:程序博客网 时间:2024/05/16 09:06
No.1 Security---------------------------------chmod g-w file_name //改变同组用户的写权限chmod 644 file_name //用绝对值来修改权限umask 022 //设置初始值权限(文件:644,目录:755)No.2 Find----------------------------------find . -name "*old*" -print //在当前路径下查询包含“old”关键字的文件find . -name "[A-Z]*" -print //在当前目录下查询包含以大写字母开头的文件find ~ -name "*.txt" -print //在$HOME 中查询文件名符合*.txt 格式的文件find / -name "*" -print //查询根目录下的所有文件find . -name "[a-z][a-z][0-9][0-9]" -print //在当前目录下查询以两个小写字母开头跟着两个数字的文件find . -perm 755 -print //在当前目录下查询权限位为755的文件,即文件属主可以读写执行,其它用户可以读执行的文件find . -user user_name -print //在当前目录下以文件属主名字来查询文件find . -group group_name -print //在当前目录下以文件用户组来查询文件find . -mtime -1 -print //在当前目录下查询更改时间子啊一日内的文件find . -newer file_name // 在当前目录下查询比file_name更改时间新的文件find . -type f -print // 在当前目录下查询 文件类型的文件find . -name "con.file" -depth -print //查询名字为con.file的文件,首先匹配所有的文件,然后再进入子目录中查询find . -type f -exec ls -l { } \ ; //在当前目录下查询文件类型的文件,然后执行ls -l 命令显示相应文件的信息find . -type f -mtime +5 -ok rm { } \ ; //在当前目录下查询文件类型,并且更新时间超过5天的文件,然后在允许的条件下删除这些文件find . type f -print | xargs chmod o-w //在当前目录下查询文件类型的所有文件,并收回other用户的写权限(xargs 和 exec区别在于,xargs对于find命令所匹配的文件,每次只获取一部分,而不是全部,逐批执行。而exec对参数长度有限制)No.3 Running on Background---------------------------------------------在$HOME目录下.profile文件添加一行:EDITOR=vi; export EDITOR0,15,30,45 09-17 * * 1-5 /bin/echo 'date' >> /scratch/ziwzhang/Documents/time_log.txt // 分 时 日 月 星期 要运行的命令, 周一到周五,9点到17点,每隔15分钟在time_log.txt文件中添加一条时间记录。crontab -l //显示当前crontab文件中的内容crontab -e //编辑crontab文件crontab -r //删除crontab文件<command> >out.file 2>&1 & //后台执行该<command>,将输出重定向到out.file 中,错误也输入到out.file中。<command> 2 > &1 > out. file //将标准输出重定向到out.file中,错误显示在终端。ps -ef | grep 28305 // 查看关于28305的进程kill 28305 /kill -9 28305 //杀死进程号为28305的进程nohup <command> //退出账户仍执行<command>No.4 文件名置换__________________________ls app* //匹配文件名以app开头,后面跟随任何字符串的文件ls conf??.log //匹配文件名以conf开头,中间是任意两个字符,最后以.log结尾的文件ls [io]* //匹配文件名以i或者o开头的文件ls log[0-9] //匹配文件以log开头,后面跟着一个数字的文件ls LPS[!0-9] //匹配文件以LPS开头,后面跟着一个非数字的文件No.5 Shell input and output__________________________cd /bin     ./sh        read name //将把所有的输入赋予给name变量echo "What is your name: " $ name //将What is your name: Wayne 这句话输出cat file_name //显示文件中的内容cat > file_name //文字编辑器,并将编辑好的文字保存到设置的file中。<crtl + D> 结束输入。ls | grep *log* //管道,检索所有文件后进行进一步筛选。date | tee -a files //在终端显示当前时间日期,并且把该时间日期保存到file中,-a:追加ls >> res.out //重定向输出cat < time_log.txt >> Test_file_1201 //以time_log.txt 的内容作为输入,重定向输出到Test_file_1201中。cat >> file_name <<MAYDAY //一个分界符到下一个分界符之间的内容重定向到file中。No.6 命令执行顺序__________________________mv /apps/bin /apps/dev/bin && rm -r /apps/bin //将/apps/bin文件夹复制到 /apps/dev/bin,如果成功,将原文件夹删除。cp file1.txt file2.txt || echo "if you are seeing this cp failed." //如果copy失败,就会执行echo命令。comet month_end || (echo "Comet did not work" | mail dave; exit) //如果comet执行不成功,发邮件给dave,然后退出。No.7 正则表达式__________________________IgnoreNo.8 grep文本过滤__________________________cat > cat_test_file_12081448 Dec 3BC1997 LPSX 68.00 LVX2A 138483 Sep 5AP1996 USP 56.00 LVX2C 18947 Oct 3ZL1998 LPSX 43.00 KVM9D 512219 DeC 2CC1999 CAD 23.00 PLV2C 68484 Nov 7PL1996 CAD 49.00 PLV2C 234483 May 5PA1998 USP 37.00 KVM9D 644216 Sep 3ZL1998 USP 86.00 KVM9E 234grep -c "48" cat_test_file_120814 //输出匹配的行数4grep "48" cat_test_file_120814 //输出匹配的行48 Dec 3BC1997 LPSX 68.00 LVX2A 138483 Sep 5AP1996 USP 56.00 LVX2C 189484 Nov 7PL1996 CAD 49.00 PLV2C 234483 May 5PA1998 USP 37.00 KVM9D 644grep -n "48" cat_test_file_120814 //输出匹配的行和行号1:48 Dec 3BC1997 LPSX 68.00 LVX2A 1382:483 Sep 5AP1996 USP 56.00 LVX2C 1895:484 Nov 7PL1996 CAD 49.00 PLV2C 2346:483 May 5PA1998 USP 37.00 KVM9D 644grep -v "48" cat_test_file_120814 //输出不匹配的行47 Oct 3ZL1998 LPSX 43.00 KVM9D 512219 DeC 2CC1999 CAD 23.00 PLV2C 68216 Sep 3ZL1998 USP 86.00 KVM9E 234grep "48\>" cat_test_file_120814 //输出精确匹配的行48 Dec 3BC1997 LPSX 68.00 LVX2A 138grep -i "nov" cat_test_file_120814 //忽略大小写,输出匹配的行484 Nov 7PL1996 CAD 49.00 PLV2C 234grep -i "cad" cat_test_file_120814 //忽略大小写,输出匹配的行219 DeC 2CC1999 CAD 23.00 PLV2C 68484 Nov 7PL1996 CAD 49.00 PLV2C 234grep '48[34]' cat_test_file_120814 //正则,单引号,输出483或者484匹配的行483 Sep 5AP1996 USP 56.00 LVX2C 189484 Nov 7PL1996 CAD 49.00 PLV2C 234483 May 5PA1998 USP 37.00 KVM9D 644grep '^48' cat_test_file_120814 //正则,输出行首为48的匹配行48 Dec 3BC1997 LPSX 68.00 LVX2A 138483 Sep 5AP1996 USP 56.00 LVX2C 189484 Nov 7PL1996 CAD 49.00 PLV2C 234483 May 5PA1998 USP 37.00 KVM9D 644grep '^[^48]' cat_test_file_120814 //正则,输出行首不为48的匹配行219 DeC 2CC1999 CAD 23.00 PLV2C 68216 Sep 3ZL1998 USP 86.00 KVM9E 234grep '[Ss]ep' cat_test_file_120814 //正则,输出Sep或者sep匹配行483 Sep 5AP1996 USP 56.00 LVX2C 189216 Sep 3ZL1998 USP 86.00 KVM9E 234grep '[Ss]ep' cat_test_file_120814 | grep "483" //正则,管道,输出Sep或者sep,并且含有484的匹配行483 Sep 5AP1996 USP 56.00 LVX2C 189grep 'K...D' cat_test_file_120814 //正则,输出K...D匹配行47 Oct 3ZL1998 LPSX 43.00 KVM9D 512483 May 5PA1998 USP 37.00 KVM9D 644grep '[A-Z][A-Z]..C' cat_test_file_120814 //正则,输出开头两个大写字母,末尾为C,并包含5个字符的匹配行483 Sep 5AP1996 USP 56.00 LVX2C 189219 DeC 2CC1999 CAD 23.00 PLV2C 68484 Nov 7PL1996 CAD 49.00 PLV2C 234grep '5..199[6,8]' cat_test_file_120814 //正则,输出5..199[6,8]的匹配行483 Sep 5AP1996 USP 56.00 LVX2C 189483 May 5PA1998 USP 37.00 KVM9D 644grep '[0-9][0-5][0-6]' cat_test_file_12081447 Oct 3ZL1998 LPSX 43.00 KVM9D 512484 Nov 7PL1996 CAD 49.00 PLV2C 234483 May 5PA1998 USP 37.00 KVM9D 644216 Sep 3ZL1998 USP 86.00 KVM9E 234grep '^[0-9][0-5][0-6]' cat_test_file_120814216 Sep 3ZL1998 USP 86.00 KVM9E 234grep '4\{2,\}' cat_test_file_120814 //正则,至少重复出现2次4的匹配行483 May 5PA1998 USP 37.00 KVM9D 644grep -E '219|216' cat_test_file_120814 //正则,出现219或者216的匹配行219 DeC 2CC1999 CAD 23.00 PLV2C 68216 Sep 3ZL1998 USP 86.00 KVM9E 234grep '^$' cat_test_file_120814 //正则,匹配空行grep '12$' cat_test_file_120814 //正则,输出以12 为行尾的匹配行47 Oct 3ZL1998 LPSX 43.00 KVM9D 512sh-4.1$ read str //匹配字符串变量Mary Joe Peter Paulinesh-4.1$ echo $str | grep "Mary"Mary Joe Peter Paulineps ax | grep "named" //匹配进程 6623 pts/2    S+     0:00 grep namedNo.9 awk从文本文件和字符串中抽取信息--------------------------------------------------------------------------cat awk_test_file_120914M.Tansley 05/99   48311   Green        8    40   44J.Lulu        06/99   48317   green        9    24   26P.Bunny    02/99   48        Yellow       12   35   28J.Troll       07/99   4842      Brown-3    12   26   26L.Tansley  05/99   4712      Brown-2    12   30   28awk '{print $0}' awk_test_file_120914 //打印所有记录awk '{print $1,$4}' awk_test_file_120914 //打印域1和域4的内容awk 'BEGIN{print "NAME   BELT\n--------------"}{print$1,$4}END{print "end of report"}' awk_test_file_120914 //打印信息头尾awk '{if($4~/Brown/) print $0}' awk_test_file_120914 //正则,如果域4匹配Brown模式,打印符合条件的信息awk '{if($3==48) print $0}' awk_test_file_120914 //精确匹配awk '{if($4!~/Brown/)print $0}' awk_test_file_120914 //不匹配awk '{if($6<$7) print $1 "try better at the next comp"}' awk_test_file_120914 //变量与字符串对接awk '/[Gg]reen/' awk_test_file_120914 //正则,打印匹配Green或green的行信息awk '$0~/(Yellow|Brown)/' awk_test_file_120914 //正则,打印匹配Yellow或者Brown的行awk '{if($1=="P.Bunny"&&$4=="Yellow")print $0}' awk_test_file_120914 //并awk 'END {print NR}' awk_test_file_120914 //输出已读记录数awk 'END{print NF}' awk_test_file_120914 //输出浏览记录的域个数awk '{name=$1;belts=$4;if(belts~/Yellow/)print name "is belt "belts}' awk_test_file_120914 //设置域变量名awk '{if($1=="M.Tansley"){ $6=$6-1; print $1,$6,$7}}' awk_test_file_120914 //赋值运算,只显示被修改的记录awk 'BEGIN{print "NAME\t DIFF"}{if($6<$7){$8=$7-$6;print $1,$8}}' awk_test_file_120914 //显示创建新的输出域awk 'total+=$6; END{print "CLUB STUDENT TOTAL POINTS; " total}' awk_test_file_120914 //显示增加列值,并显示全部记录awk '{total+=$6;} END{print "CLUB STUDENT TOTAL POINTS; " total}' awk_test_file_120914 //只输出增加列值awk 'gsub(/4842/,4899){print $0}' awk_test_file_120914 //在整个记录中替换一个字符串为另一个awk 'BEGIN{print length("THIS IS A TEST!")}' //显示字符串的长度awk 'BEGIN{print match("ABCD","C")}' //显示首位置匹配的字符数awk 'BEGIN{print split("123#456#789",myarray,"#")}' //显示数组myarray的下表数awk '$1=="L.Tansley" {print substr($1,1,5)}' awk_test_file_120914No.10 sed文本编辑----------------------------------------------------------------------cat sed_test_file_121614The honeysuckle band played all night long for only $90.It was an evening of splendid music and company.Too bad the disco floor fell through at 23:10.The local nurse Miss P.Neave was in attendance.sed -n '2p' sed_test_file_121614 //只显示第二行It was an evening of splendid music and company.sed -n '1,3p' sed_test_file_121614 //显示一到三行The honeysuckle band played all night long for only $90.It was an evening of splendid music and company.Too bad the disco floor fell through at 23:10.sed -n '/Neave/p' sed_test_file_121614 // 只显示匹配的行The local nurse Miss P.Neave was in attendance.sed -n '4, /The/p' sed_test_file_121614 // 只在第四行查询匹配并显示The local nurse Miss P.Neave was in attendance.sed -n '/\$/p' sed_test_file_121614 //反斜杠屏蔽其特殊含义The honeysuckle band played all night long for only $90.sed -n '1,$p' sed_test_file_121614 //显示整个文件The honeysuckle band played all night long for only $90.It was an evening of splendid music and company.Too bad the disco floor fell through at 23:10.The local nurse Miss P.Neave was in attendance.sed -n '/music/=' sed_test_file_121614 //只显示匹配的行号2sed -n -e '/music/p' -e '/music/=' sed_test_file_121614 //显示匹配行和行号It was an evening of splendid music and company.2sed '/company/a\Then suddenly it happened.' sed_test_file_121614 > sed.out //在匹配行后下一行附加文本,并将输出结果输入到sed.outThe honeysuckle band played all night long for only $90.It was an evening of splendid music and company.Then suddenly it happened.Too bad the disco floor fell through at 23:10.The local nurse Miss P.Neave was in attendance.sed '/attendance/i\utter confusion followed.' sed_test_file_121614 //在匹配行前一行插入文本。The honeysuckle band played all night long for only $90.It was an evening of splendid music and company.Too bad the disco floor fell through at 23:10.utter confusion followed.The local nurse Miss P.Neave was in attendance.sed '/honeysuckle/c\The Office Dibble band played well' sed_test_file_121614 //替换匹配行The Office Dibble band played wellIt was an evening of splendid music and company.Too bad the disco floor fell through at 23:10.The local nurse Miss P.Neave was in attendance.sed '1d' sed_test_file_121614 // 删除第一行It was an evening of splendid music and company.Too bad the disco floor fell through at 23:10.The local nurse Miss P.Neave was in attendance.sed 's/night/Night/' sed_test_file_121614 //替换文本The honeysuckle band played all Night long for only $90.It was an evening of splendid music and company.Too bad the disco floor fell through at 23:10.The local nurse Miss P.Neave was in attendance.sed 's/The/Wow/g' sed_test_file_121614 // 全局替换Wow honeysuckle band played all Night long for only $90.It was an evening of splendid music and company.Too bad the disco floor fell through at 23:10.Wow local nurse Miss P.Neave was in attendance.sed 's/splendid/Splendid/w sed.out' sed_test_file_121614 //将替换行输入到sed.out 文件中It was an evening of Splendid music and company.sed -n 's/nurse/"Hello" &/p' sed_test_file_121614 // 在匹配文本之前附加“Hello”The local "Hello" nurse Miss P.Neave was in attendance.sed -n 's/company/& place/p' sed_test_file_121614 //在匹配文本之后附加placeIt was an evening of splendid music and company place.sed '/company/r sed.out' sed_test_file_121614 //从文件中读文本,并附加到匹配行后下一行The honeysuckle band played all night long for only $90.It was an evening of splendid music and company.This is test !Too bad the disco floor fell through at 23:10.The local nurse Miss P.Neave was in attendance.No.11 合并与分割-------------------------------------------------------cat sort_test_file_121814Boys in Company C:HK:192:2192Alien:HK:119:1982The Hill:KL:63:2972Aliens:HK:532:4892Star Wars:HK:301:4102A Few Good Men:KL:445:5851Toy Story:HK:239:3972Alien:HK:119:1982sort -t: sort_test_file_121814 //-t: 分隔符,按第一域分类A Few Good Men:KL:445:5851Alien:HK:119:1982Alien:HK:119:1982Aliens:HK:532:4892Boys in Company C:HK:192:2192Star Wars:HK:301:4102The Hill:KL:63:2972Toy Story:HK:239:3972sort -t: -r sort_test_file_121814 // 按第一域逆向排序Toy Story:HK:239:3972The Hill:KL:63:2972Star Wars:HK:301:4102Boys in Company C:HK:192:2192Aliens:HK:532:4892Alien:HK:119:1982Alien:HK:119:1982A Few Good Men:KL:445:5851sort -t: -k3 sort_test_file_121814 //按第三域排序,只看第三域第一个数字大小。Alien:HK:119:1982Alien:HK:119:1982Boys in Company C:HK:192:2192Toy Story:HK:239:3972Star Wars:HK:301:4102A Few Good Men:KL:445:5851Aliens:HK:532:4892The Hill:KL:63:2972sort -t: -k3 -n sort_test_file_121814 //按第三域数值大小排列The Hill:KL:63:2972Alien:HK:119:1982Alien:HK:119:1982Boys in Company C:HK:192:2192Toy Story:HK:239:3972Star Wars:HK:301:4102A Few Good Men:KL:445:5851Aliens:HK:532:4892sort -u sort_test_file_121814 //去除重复行A Few Good Men:KL:445:5851Alien:HK:119:1982Aliens:HK:532:4892Boys in Company C:HK:192:2192Star Wars:HK:301:4102The Hill:KL:63:2972Toy Story:HK:239:3972sort -t: -k1.2 sort_test_file_121814 //按第一域第二个字符排序A Few Good Men:KL:445:5851The Hill:KL:63:2972Alien:HK:119:1982Alien:HK:119:1982Aliens:HK:532:4892Toy Story:HK:239:3972Boys in Company C:HK:192:2192Star Wars:HK:301:4102sort -t: -r -k4 sort_test_file_121814 | head -1 //显示按第四域逆排序最大值A Few Good Men:KL:445:5851sort -t: -r -k4 sort_test_file_121814 | tail -1 //显示按第四域逆排序最小值Alien:HK:119:1982cat sort2May DayMay DayMay DayJan DayJan DayMay Dayuniq -u sort2 //只显示不重复行May Dayuniq -d sort2 //只显示有重复行May DayJan Dayuniq -c sort2 //打印显示重复行数目3 May Day2 Jan Day1 May Daycat join_test1M.Golls 12 Hidd RdP.Heller The AcreP.Willey 132 The GroveT.Norms 84 Connaught RdK.Fletch 12 Woodleacat join_test2M.Golls Norwich NRDP.Willey Galashiels GDDT.Norms Brandon BSLK.Fletch Mildenhall MAFjoin join_test1 join_test2 //连接两个文件K.Fletch 12 Woodlea Mildenhall MAFM.Golls 12 Hidd Rd Norwich NRDP.Willey 132 The Grove Galashiels GDDT.Norms 84 Connaught Rd Brandon BSLjoin -a1 -a2 join_test1 join_test2 //不匹配连接K.Fletch 12 Woodlea Mildenhall MAFM.Golls 12 Hidd Rd Norwich NRDP.Heller The AcreP.Willey 132 The Grove Galashiels GDDT.Norms 84 Connaught Rd Brandon BSLjoin -o 1.1,2.2 join_test1 join_test2 //显示第一个文件第一域和第二个文件第二个域K.Fletch MildenhallM.Golls NorwichP.Willey GalashielsT.Norms Brandoncut -d: -f1-3 sort_test_file_121814 //剪切第1-3域的内容Boys in Company C:HK:192Alien:HK:119The Hill:KL:63Aliens:HK:532Star Wars:HK:301A Few Good Men:KL:445Toy Story:HK:239Alien:HK:119cut -c1-6 sort2 //剪切1-6的字符May DaMay DaMay DaJan DaJan DaMay Dacut -c1,6 sort2 //剪切1和6的字符MaMaMaJaJaMaNo.12 tr字符替换和删除_______________________________cat oops.txtAnd the cowwwwws went homeeeeeeeeeor did theyyyytr -s "[a-z]" <oops.txt //去除重复字母,使用-sAnd the cows went homeor did theycat plane.txt987932 Spitfire190993 Lancaster238991 Typhoontr -s "[\n]" < plane.txt //去除空行987932 Spitfire190993 Lancaster238991 Typhoonecho "May Day, May Day, Going Down.." | tr "[a-z]" "[A-Z]" //大写替换小写MAY DAY, MAY DAY, GOING DOWN..No.13  登录环境_______________________________IgnoreNo.14  Shell 变量_______________________________本地变量:sh-4.1$ set //显示所有本地shell变量FULLNAME="WAYNE GRANGE" //设置变量FULLNAME,并显示sh-4.1$ echo ${FULLNAME}WAYNE GRANGEunset FULLNAMEsh-4.1$ echo "My name is ${FULLNAME:-Wayne Granger}" //如果未设置变量FULLNAME值,设置其值,但不存储My name is Wayne Grangerecho "The file is ${FILES:?}" //测试变量是否取值sh: FILES: parameter null or not setreadonly //查看所有只读变量readonly FULLNAME //将变量设置为只读变量环境变量:env //可以查看所有的环境变量CONSOLE=tty1; export CONSOLE //设置环境变量并显示echo $CONSOLEtty1位置变量:cat > plane.txt#!/bin/sh# allparamsecho "This is the script name  :$0"echo "This is the first parameter  :$1"echo "This is the second parameter  :$2"echo "This is the third parameter  :$3"echo "This is the fourth parameter  :$4"echo "This is the fifth parameter  :$5"echo "This is the sixth parameter  :$6"echo "This is the seventh parameter  :$7"echo "The number of arguments passed  :$#"echo "Show all arguments  :$*"echo "Show me my process ID  :$$"echo "Did my script go with any errors  :$?"./plane.txt Merry Chirstmas Mr LawrenceThis is the script name  :./plane.txtThis is the first parameter  :MerryThis is the second parameter  :ChirstmasThis is the third parameter  :MrThis is the fourth parameter  :LawrenceThis is the fifth parameter  :This is the sixth parameter  :This is the seventh parameter  :The number of arguments passed  :4Show all arguments  :Merry Chirstmas Mr LawrenceShow me my process ID  :13387Did my script go with any errors  :0No.15 引号-----------------------------------------------------------expr 12 \* 12 // \屏蔽特殊含义144echo `date` // 反引号用于设置系统命令的输出Tue Dec 23 21:51:46 PST 2014No.16 Shell Script——————————————————ignoreNo.17 条件测试__________________________________test -w plane.txt //测试文件是否可写echo $?0test -x sort2 //测试文件是否可执行echo $?1test -f shfis -o -x plane.txt //测试是否存在文件shfis或者文件plane是否可执行,两者之一为真,结果为真echo $?0test -f shfis -a -x plane.txt //与echo $?1test "shift" = "shisFt"echo $? //测试两个字符串是否相等1sh-4.1$ Number=130 //测试两个数值是否相等sh-4.1$ test $Number -eq "130"sh-4.1$ echo $?0sh-4.1$ expr 10 + 10 //数值计算20No.18 控制流结构________________________________if then elseex.  3Paras.src            create_file.src         findname.src       show_name.src       copy_file.srccaseex.  weeklyreport.srcforex.  filecounter.srcwhileex.  while_read.srcNo.19 Shell 函数________________________________查看字符串长度的函数check_length将文件内容修改为大写的函数file_to_upper只允许字符名字输入的函数name_fuc给文件标出行号的函数number_file将字符串修改为大写的函数str_to_upperNo.20 向脚本传递参数________________________________How to use shift to pass parameters to script:shift_caseNo.21 创建屏幕输出坐标函数cup_case使用颜色,坐标,居中等函数的屏幕输出:output_screenNo.22—————————————————IgnoreNo.23 调试脚本________________________________set -x //可以辅助脚本调试set +x //关闭脚本调试No.24 Shell嵌套命令_________________________________嵌入命令实在实际的shell里创建的而不是存在于/bin目录里。嵌入命令比相同的系统命令快的多。No.25 <<的作用_________________________________快速创建一个文件cat >> myfile << MAYDAY*****MAYDAY //分隔符的作用快速创建打印文档自动ftp传输ftp 传输:ftp -i -n slc03qdiuser aime1PASSWORD: *******lcd /scratch/user/Documents/get remotefilesexitNo.26 Shell工具——————————————————date +%d%m%y //以年月日的形式输出日期120115date +%A //输出星期Mondaydate +%e //输出日12date +%R //输出时间19:11date +%p //输出上下午PMdate +%T //输出完整时间19:14:00注意:如果希望在日期和时间的显示中包含空格,要使用双引号捕获信号并采取行动trap “commands” 2 //trap_signal.srcMyfile="cat /scratch/ziwzhang/Documents/File_Test/eval_test"echo $Myfilecat /scratch/ziwzhang/Documents/File_Test/eval_testeval $Myfile //两次扫描变量May Day, May DayGoing DownNo.27 脚本案例__________________________________pingall //ping 文本上所有的主机地址No.28 运行级别脚本__________________________________IgnoreNo.29 cgi脚本__________________________________ignoreNo.30 常用命令__________________________________zip命令:zip -r filename.zip file 

0 0
原创粉丝点击