basicsys@mars~/lec4>cat F1 abcde 12345 abcdefghi basicsys@mars~/lec4>cut -c1,4- F1 ade 145 adefghi basicsys@mars~/lec4>x=F1 basicsys@mars~/lec4>cut -c1,4- $x ade 145 adefghi basicsys@mars~/lec4>x=abc basicsys@mars~/lec4>cut -c1,4- $x cut: abc: No such file or directory basicsys@mars~/lec4>cat F1 abc de fg yx zz 12 345 abc 555 abcdefghi 12 555 7 8 9 basicsys@mars~/lec4>cut -d" " -f1,3,5 F1 abc fg zz 12 abc abcdefghi 555 8 basicsys@mars~/lec4>cut -d" " -f1,3,5 F1 --output-delimiter=rtuq abcrtuqfgrtuqzz 12rtuqabcrtuq abcdefghirtuq555rtuq8 basicsys@mars~/lec4>cut -d" :" -f1,3,5 F1 --output-delimiter=rtuq cut: the delimiter must be a single character Try `cut --help' for more information. basicsys@mars~/lec4>cat F2 ab"cd"ef 1234"5678"12 basicsys@mars~/lec4>cut -d"\"" -f1,3 F2 ab"ef 1234"12 basicsys@mars~/lec4>cat F3 123456 ab basicsys@mars~/lec4>wc F3 2 2 10 F3 basicsys@mars~/lec4>wc abc defg 2 2 9 basicsys@mars~/lec4>cut -d" " -f1,3,5 12 34 56 78 90 1 2 3 4 5 6 12 56 90 1 3 5 basicsys@mars~/lec4>cat 12345 12345 abcd abcd basicsys@mars~/lec4>wc F1 3 15 55 F1 basicsys@mars~/lec4>wc < F1 3 15 55 basicsys@mars~/lec4>wc -l < F1 3 basicsys@mars~/lec4>cat F1 abc de fg yx zz 12 345 abc 555 abcdefghi 12 555 7 8 9 basicsys@mars~/lec4>cat F2 ab"cd"ef 1234"5678"12 basicsys@mars~/lec4>wc F1 - F2 3 15 55 F1 123456 ab 2 2 10 - 2 2 22 F2 7 19 87 total basicsys@mars~/lec4>wc - 123456 1b 2 2 10 - basicsys@mars~/lec4>cat F1 abc de fg yx zz 12 345 abc 555 abcdefghi 12 555 7 8 9 basicsys@mars~/lec4>cat F2 ab"cd"ef 1234"5678"12 basicsys@mars~/lec4>cat F3 123456 ab basicsys@mars~/lec4>wc F1 - F2 < F3 3 15 55 F1 2 2 10 - 2 2 22 F2 7 19 87 total basicsys@mars~/lec4>cat F1 - F2 < F3 abc de fg yx zz 12 345 abc 555 abcdefghi 12 555 7 8 9 123456 ab ab"cd"ef 1234"5678"12 basicsys@mars~/lec4>cat F1 10 300 5 2000 basicsys@mars~/lec4>sort -n F1 5 10 300 2000 basicsys@mars~/lec4>sort -n -r F1 2000 300 10 5 basicsys@mars~/lec4>sort F1 10 2000 300 5 basicsys@mars~/lec4>sort 158 15499 15499 158 basicsys@mars~/lec4>sort -n 158 15499 158 15499 basicsys@mars~/lec4>x="12 34 56" basicsys@mars~/lec4>echo "$x" >| tmp basicsys@mars~/lec4>cut -d" " -f1,3 < tmp 12 56 basicsys@mars~/lec4>echo $x | cut -d" " -f1,3 12 56 basicsys@mars~/lec4>cat F1 10 300 5 2000 basicsys@mars~/lec4>sort F1 >| tmp basicsys@mars~/lec4>sort -n F1 >| tmp basicsys@mars~/lec4>tail -1 < tmp 2000 basicsys@mars~/lec4>cat F1 10 300 5 2000 basicsys@mars~/lec4>sort -n F1 >| tmp basicsys@mars~/lec4>tail -1 < tmp 2000 basicsys@mars~/lec4>sort -n F1 | tail -1 2000 basicsys@mars~/lec4>wc -l F* 4 F1 2 F2 2 F3 8 total basicsys@mars~/lec4>wc -l F* | cut -d" " -f2 4 2 2 8 basicsys@mars~/lec4>wc -l F* | cut -d" " -f2 | sort -n | tail -2 | head -1 4 basicsys@mars~/lec4>cat F1 10 300 5 2000 basicsys@mars~/lec4>echo $x | cut -c1 x=gggg basicsys@mars~/lec4>echo $x | cut -c1 echo $x | cut -c1 F1 1 3 5 2 basicsys@mars~/lec4>echo $x | cut -c1 g basicsys@mars~/lec4>cat P1 #!/bin/bash sum=0 for x in 4 60 100 do sum=$[$sum+$x] done echo $sum basicsys@mars~/lec4>P1 164 basicsys@mars~/lec4>cat P2 #!/bin/bash sum=0 for x in $(seq 10) do sum=$[$sum+$x] done echo $sum basicsys@mars~/lec4>P2 55 basicsys@mars~/lec4>cat P3 #!/bin/bash for x in "ab cd" "efff gh" 1234 do echo "$x" done basicsys@mars~/lec4>P3 ab cd efff gh 1234 basicsys@mars~/lec4>cat P4 #!/bin/bash sum=0 for x in $* do sum=$[$sum+$x] done echo $sum basicsys@mars~/lec4>P4 10 20 30 60 basicsys@mars~/lec4>P4 10 20 30 50 110 basicsys@mars~/lec4>cat P5 #!/bin/bash echo "the first parameter is $1" echo "the second parameter is $2" echo "the number of parameters $#" echo "all the parameters are: $*" echo "all the parameters are: $@" basicsys@mars~/lec4>P5 10 ab cd 20 gh the first parameter is 10 the second parameter is ab the number of parameters 5 all the parameters are: 10 ab cd 20 gh all the parameters are: 10 ab cd 20 gh basicsys@mars~/lec4>cat P6 #!/bin/bash x=0 while [ $x -lt 5 ] do echo $x x=$[$x+1] done echo I finished the program basicsys@mars~/lec4>P6 0 1 2 3 4 I finished the program basicsys@mars~/lec4>cat P7 #!/bin/bash while read x do if [ $x -gt 5 ] then if [ $x -le 20 ] then echo $x fi fi done echo I finished the program basicsys@mars~/lec4>P7 60 2 5 8 8 I finished the program basicsys@mars~/lec4>cat F1 10 300 5 2000 basicsys@mars~/lec4>cat P8 #!/bin/bash while read x do if [ $x -gt 5 ] then if [ $x -le 20 ] then echo $x fi fi doneP8 10 I finished the program ********* basicsys@mars~/lec4>echo -n abc abcbasicsys@mars~/lec4>echo -n abc | wc -c 3 basicsys@mars~/lec4>x=abc basicsys@mars~/lec4>y=de basicsys@mars~/lec4>z="$x:$y" basicsys@mars~/lec4>echo $z abc:de basicsys@mars~/lec4>z=$(echo $x | cut -d" " -f$1)