Weeks 4 - 6
Review of Linux:
Lab exercises --
#1 Write a script which takes an integer, n<10, as input and builds an n x n multiplication table written in html in your own public_htm directory.
Hint:echo $1 is the number you gave me.
count=0
echo "<html><table border=1>"
while [ $count -lt $1 ]
do
echo "<tr><td>"$count"</td></tr>"
count=`expr $count + 1`
done
#2 Write a script which prints each input parameter on a separate line, with each line beginning with the parameter number.
The program would run as shown here:
making and testing cgi./param a aardvark b 12 ragweed1 a
2 aardvark
3 b
4 12
5 ragweed
$ echo $p
/home/SRUNET/david.dailey/data/places.txt
$ grep -i "grove city" $p|head
01 61008 Pleasant Grove city AL 8458 [...]
05 57170 Prairie Grove city AR 1761 [...]
06 29000 Garden Grove city CA 143050 [...]
06 41124 Lemon Grove city CA 23984 [...]
06 54848 Pacific Grove city CA 16117 [...]
12 27775 Grove City CDP FL 2374 [...]
13 47140 Locust Grove city GA 1681 [...]
17 42769 Leland Grove city IL 1679 [...]
17 77941 Villa Grove city IL 2734 [...]
18 04204 Beech Grove city IN 13383 [...]
$ s="\""
$ for i in grove city; do s=$s`echo \ $i`; done
$ echo $s
" grove city
$ s=$s\"
$ echo $s
" grove city"
However:
]$ grep -i $s $p|head
grep: grove: No such file or directory
grep: city": No such file or directory
AL [...]
Now observe this:
$ s=""
$ for i in `echo grove city`; do s=$s$i\\\ ; done
$ echo $s
grove\ city\
$ sed -n /"$s"/p $p
41 62250 Rivergrove city OR [...]
Special: notes on dictionaries and other resources
Assignment #3: Due date : Wednesday, October 5th
Assignment #4: Due date: Monday, October 10th