basicsys@mars~>echo -n aabbaba |egrep -o a a a a a basicsys@mars~>echo -n aabbaba |egrep -o a | wc -l 4 basicsys@mars~>echo aba | tr a "\n" | wc -l 3 basicsys@mars~>echo -n aba | tr a "\n" | wc -l 2 basicsys@mars~>x=$(echo -n aba |wc -c) basicsys@mars~>y=$(echo -n aba | tr -d a | wc -c) basicsys@mars~>echo $[$x-$y] basicsys@mars~/lec9>ls -l P1 -rwx------ 1 basicsys basicsys 170 Dec 17 10:15 P1 basicsys@mars~/lec9>ls -l --time=atime P1 -rwx------ 1 basicsys basicsys 170 Dec 21 20:51 P1 basicsys@mars~/lec9>ls -l --time=ctime P1 -rwx------ 1 basicsys basicsys 170 Dec 17 10:16 P1 basicsys@mars~/lec9>chmod u-x P1 basicsys@mars~/lec9>ls -l --time=ctime P1 -rw------- 1 basicsys basicsys 170 Dec 25 19:08 P1 basicsys@mars~/lec9>ls -l P1 -rw------- 1 basicsys basicsys 170 Dec 17 10:15 P1 basicsys@mars~/lec9>cat P1 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~/lec9>ls -l --time=atime P1 -rw------- 1 basicsys basicsys 170 Dec 25 19:08 P1 basicsys@mars~/lec9>date Tue Dec 25 19:09:30 IST 2012 basicsys@mars~/lec9>echo aa >> P1 basicsys@mars~/lec9>ls -l P1 -rw------- 1 basicsys basicsys 173 Dec 25 19:10 P1 basicsys@mars~/lec9>ls -l --time=ctime P1 -rw------- 1 basicsys basicsys 173 Dec 25 19:10 P1 basicsys@mars~/lec9> basicsys@mars~/lec9>cat P1 #!/bin/bash for x in $* do echo "$x" done for x in $@ do echo "$x" done for x in "$*" do echo "$x" done for x in "$@" do echo "$x" done basicsys@mars~/lec9>P1 "ab cd" "ef gh" ab cd ef gh ab cd ef gh ab cd ef gh ab cd ef gh basicsys@mars~/lec9>cat P2 #!/bin/bash echo $* echo $# shift echo $* echo $# shift echo $* echo $# basicsys@mars~/lec9>P2 10 20 30 40 10 20 30 40 4 20 30 40 3 30 40 2 basicsys@mars~/lec9>cat P3 #!/bin/bash s=0 while [ $# -ge 1 ] do s=$[$s+$1] shift done echo $s basicsys@mars~/lec9>P3 10 20 30 60 basicsys@mars~/lec9>cat P16 #!/bin/bash read x case $x in a) echo "you typed a";; b|c) echo "you typed b or c";; g*) echo "you typed a string that starts with g";; f??) echo "you typed a string that starts with f followd by exa echo " two charactres";; *) echo "you typed nothing of the first options";; esac basicsys@mars~/lec9>P16 yyyy you typed nothing of the first options basicsys@mars~/lec9>P16 a you typed a basicsys@mars~/lec9>P16 b you typed b or c basicsys@mars~/lec9>P16 fabc you typed nothing of the first options basicsys@mars~/lec9>P16 f1u you typed a string that starts with f followd by exactly two charactres basicsys@mars~/lec9>cat P16.1 #!/bin/bash case "$1" in [a-c]r[a-c]) echo "you typed one of a,b,c followd by r followd" echo " bye one of a,b,c";; *aef[wqs]?) echo "you typed any sring followd by aef followd by" echo "one of w,q,s followd by one character";; ?) echo "you typed exactly one character";; ?*) echo "you typed at least one chacter";; *) echo "you typed nothing of the first options";; esac basicsys@mars~/lec9>P16.1 abcrabc you typed at least one chacter basicsys@mars~/lec9>P16.1 arc you typed one of a,b,c followd by r followd bye one of a,b,c basicsys@mars~/lec9>P16.1 rzqwefzaefw you typed at least one chacter basicsys@mars~/lec9>P16.1 rzqwefzaefwtr you typed at least one chacter basicsys@mars~/lec9>P16.1 rzqwefzaefwt you typed any sring followd by aef followd by one of w,q,s followd by one character basicsys@mars~/lec9>P16.1 w you typed exactly one character basicsys@mars~/lec9>P16.1 you typed nothing of the first options basicsys@mars~/lec9>tree t t |-- d1 | |-- d3 | | |-- a1 | | |-- f2 | | `-- f3 | `-- f4 |-- d2 | `-- d3 | `-- f5 `-- f1 5 directories, 5 files basicsys@mars~/lec9>find t -name f5 -print t/d2/d3/f5 basicsys@mars~/lec9>find t -name f* -print t/d1/f4 t/d1/d3/f2 t/d1/d3/f3 t/f1 t/d2/d3/f5 basicsys@mars~/lec9>find t -name f* -print -print t/d1/f4 t/d1/f4 t/d1/d3/f2 t/d1/d3/f2 t/d1/d3/f3 t/d1/d3/f3 t/f1 t/f1 t/d2/d3/f5 t/d2/d3/f5 basicsys@mars~/lec9>find t -name f* t/d1/f4 t/d1/d3/f2 t/d1/d3/f3 t/f1 t/d2/d3/f5 basicsys@mars~/lec9>ls -l t total 12 drwx------ 3 basicsys basicsys 4096 Dec 24 18:17 d1 drwx------ 3 basicsys basicsys 4096 Dec 17 10:40 d2 -rw------- 1 basicsys basicsys 37 Dec 24 18:19 f1 basicsys@mars~/lec9>find t -size 37c t/f1 basicsys@mars~/lec9>find t -size +37c t t/d1 t/d1/d3 t/d1/d3/f2 t/d1/d3/f3 t/d1/d3/a1 t/d2 t/d2/d3 basicsys@mars~/lec9>find t -size -37c t/d1/f4 t/d2/d3/f5 basicsys@mars~/lec9>find -name a* -o -size 37c ./t/d1/d3/a1 ./t/f1 basicsys@mars~/lec9>find t -name a* -size 37c basicsys@mars~/lec9>find t \( -name a* -o -size 37c \) -mmin -100 basicsys@mars~/lec9>find t \( -name a* -o -size 37c \) -mmin +100 t/d1/d3/a1 t/f1