资源预览内容
第1页 / 共14页
第2页 / 共14页
第3页 / 共14页
第4页 / 共14页
第5页 / 共14页
第6页 / 共14页
第7页 / 共14页
第8页 / 共14页
第9页 / 共14页
第10页 / 共14页
亲,该文档总共14页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述
第四章第四章 BEGIN for(x=0;x ARGV.AWK #!/bin/awk -f BEGIN FS=“,“ split($1,name,“ “);for(i in name) print namei ARRAY.AWK #!/bin/sed -f /CcEeRrTtIiFfIiCcAaTtEe/d DELETE.SED #!/bin/awk -f BEGIN FS=“,“; if(ARGC2)name=ARGV1;delete ARGV1 else while(!name)print “Pls. Enter a name“; getline nameFINDPHON.AWK #!/bin/sed -f /file:/i We insert a new line. INSERT.SED #!/bin/sed -f /file:/c We modify this line. MODIFY.SED #!/bin/awk -f NF!=MAX print(“The line “NR“ does not have “MAX“ filds“) PASS.AWK #src1.awk:打印空白行 #!/bin/awk -f /$/print “This is a blank line.“ SCR1.AWK #!/bin/awk -f BEGIN FS=“,“ total=$4+$5+$6+$7+$8 avg=total/5 print $1,avg SCR2.AWK 第五章第五章 BEIJING:86010 HONGKONG:852 SHANGHAI:86021 TORONTO:001416 AREACODE.DB ThinkPad:USA:14000:2009:X301 ThinkPad:USA:14000:2009:X301 ThinkPad:USA:14000:2009:X301 HP:China:5600:2010:DM3 SumSung:Korea:5400:2009:Q308 ThinkPad:USA:14000:2009:X301 IdeaPad:China:8000:2007:U450 Acer:Taiwan:8000:2010:PT210 Acer:Taiwan:8000:2010:PT210 CARGO.DB DELL:USA:6700:2009:XPS MACBOOK:USA:10198:2010:MB991ZP/A CARGO2.DB #!/bin/bash ARGS=1 E_BADARGS=55 E_NOFILE=56 if $# -ne “$ARGS“ then echo “Usage: basename $0 filename“ exit $E_BADARGS fi if ! -f “$1“ then echo “File “$1“ does not exits.“ exit $E_NOFILE fi sed -e s/./g -e s/,/g -e s/:/g -e s/ /n/g “$1“ | sort | uniq -c | sort -nr COUNT_WO.SH J Luo Southeast University Nanjing,China Y Zhang Victory University Melbourne, Australia D Hou Beijing University Beijing,China B Liu Shanghai Jiaotong University Shanghai,China C Lin University of Toronto Toronto,Canada PROFESSO.DB Acer:Taiwan:8000:2010:PT210 HP:China:12000:2010:NE808 HP:China:5600:2010:DM3 IdeaPad:China:8000:2007:U450 SumSung:Korea:5400:2009:Q308 ThinkPad:HongKong:10000:2008:T400 ThinkPad:USA:14000:2009:X301 ThinkPad:USA:8000:2007:X60 SORT_CAR.DB B Liu:Shanghai Jiaotong University:Shanghai:China C Lin:University of Toronto:Toronto:Canada D Hou:Beijing University:Beijing:China J Luo:Southeast University:Nanjing:China Y Zhang:Victory University:Melbourne:Australia TEACHER.DB B Liu:Tea C Lin:Song J Cao:Pingpong Q Cai:Shopping Y Zhang:Photograhy Z Wu:Chess TEACHER_.DB D Hou:Beijing University:Beijing:China Y Zhang:Victory University:Melbourne:Australia J Luo:Southeast University:Nanjing:China B Liu:Shanghai Jiaotong University:Shanghai:China C Lin:University of Toronto:Toronto:Canada TEACHER1.DB 第六章第六章 #!/bin/bash echo “Child Process ID is $“ echo “My Father Process ID is $PPID“ echo “localvar=$localvar“ echo “ENVVAR=$ENVVAR“ localvar=“Redefine this local variable.“ ENVVAR=“Redefine this environment variable.“ echo “localvar=$localvar“ echo “ENVVAR=$ENVVAR“ CHILD.SH #!/bin/bash variable1=2010 echo “$variable1“ echo $variable1 variable2=“X Y Z“ echo “$variable2“ echo $variable2 DOUBLE.SH #!/bin/bash echo “ ECHOES.SH #!/bin/bash echo “tnav“ echo -e “tttthello“ echo -e “hellovvvvhello“ echo -e “aaaa“ echo -e “042“ ESCAPE.SH #!/bin/bash echo “Father Process ID is $“ localvar=“Define a local variable.“ echo “localvar=$localvar“ ENVVAR=“Define a environment variable.“ export ENVVAR echo “ENVVAR=$ENVVAR“ $PWD/child.sh echo “Return to father process: $“ echo “localvar=$localvar“ echo “ENVVAR=$ENVVAR“ FATHER.SH #!/bin/bash a=2009 let “a+=1“ echo “a=$a“ b=xx09 echo “b=$b“ declare -i b echo “b=$b“ let “b+=1“ echo “b=$b“ exit 0 INTEGER.SH #!/bin/bash c=“ echo “c=$c“ let “c+=1“ echo “c=$c“ echo “e=$e“ let “e+=1“ echo “e=$e“ exit 0 NULL_UND.SH #!/bin/sh echo “The script name is: $0“ #$0 echo “Parameter #1$1“ echo “Parameter #2$2“ echo “Parameter #3$3“ echo “Parameter #4$4“ echo “Parameter #5$5“ echo “Parameter #6$6“ echo “Parameter #7$7“ echo “Parameter #8$8“ echo “Parameter #9$9“ echo “Parameter #10$10“ # echo “-“ echo “All the command line parameters are: $*“ POSITION.SH #include main () printf (“This is the output from C program.“); SIMPLEC.C #!/bin/bash echo “Why cant I write s between single quotes“ echo Why can“t I write “s between single quotes STEPHANE.SH #!/bin/bash variable=“($“ echo $variable echo “$variable“ IFS= echo $variable echo “$variable“ exit 0 WEIRDVAR.SH 第七第七章章 #case_exam2.sh: #!/bin/bash echo “Please Input a score_type(A-E): “ read score_type case “$score_type“ in A) echo “The range of score is from 90 to 100 !“; B) echo “The range of score is from 80 to 89 !“; C) echo “The range of score is from 70 to 79 !“; D) echo “The range of score is from 60 to 69 !“; E) echo “The range of score is from 0 to 59 !“; *) echo “What you input is wrong !“; esac CASE_EX2.SH #case_exam1.sh: #!/bin/bash echo “Ple
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号