I-2 055702B : 2006 5 1 2006 5 8 2006 5 10 1
1 Level 1 myls / $ ls -FC /foo dir1/ le1 dir2/ le2 $ myls /foo dir1/ dir2/ le1 le2 Level 2 (myupper) (mymv). % ls le1.txt le2.tex le3.dat % myuppper le1.txt le2.tex % ls FILE1.TXT FILE2.TEX le3.dat % ls le1.ps le2.ps le3.ps % mymv eps *ps % ls le1.eps le2.eps le3.eps 2
Level 3 thumbnail3.sh 1 photo num,. photo num pagename (photos) photo num=1 page1.html (photo1) page2.html (photo2) page3.html (photo3) page4.html (photo4) page5.html (photo5) page1.html (photo1, 2) photo num=2 page2.html (photo3, 4) page3.html (photo5) photo num=3 page1.html (photo1, 2, 3) page2.html (photo4, 5) Level 4.1 access log Level 4.2 IP Level 4.3 Level 4.2. IP IP 10 3
2 (1) Level 1 -myls.sh- #!/bin/sh if [ $# -lt 1 ] ; then echo "Usage: prg xx " elif [ $# -gt 1 ] ; then echo " 1 " # # if [! -e./$1 ] ; then echo "$1 " # if [! -d./$1 ] ; then echo "$1 " # echo "----directry----" for le in ls -1 $1 if [ -d./$1/$le ] ; then echo "$le/" ne echo "------le------" for le in ls -1 $1 if [ -f./$1/$le ] ; then echo "$le" ne echo "----unknown?----" for le in ls -1 $1 if [! -d./$1/$le -a! -f./$1/$le ] ; then echo "Not directory or le" ne 4
(2) Level 2 [j05002@myls]% ls FILE1.TXT le3.txt myls.sh* sample1/ FILE2.TXT le4.txt myls.sh~* test1/ [j05002@myls]% sh myls.sh./ ----directry---- sample1/ test1/ ------le------ FILE1.TXT FILE2.TXT le3.txt le4.txt myls.sh myls.sh~ ----unknown?---- 1. ls -1 1 1.,. -myupper.sh- #!/bin/sh if [ $# -lt 1 ] ; then echo "Usage: prg xx" # for lename in $* if [ -f $lename ] ; then # after= echo $lename tr [a-z] [A-Z] # mv $lename $after else echo "$lename " ne [j05002@myupper]% ls le1.txt le2.txt le3.txt le4.txt myupper.sh* myupper.sh~* [j05002@myupper]% sh myupper.sh le1.txt le2.txt [j05002@myupper]% ls FILE1.TXT FILE2.TXT le3.txt le4.txt myupper.sh* myupper.sh~* 1. tr. (, ) tr : tr [ ] 1 [ 2] 5
: -d 1, -s 1 1 -mymv.sh- #!/bin/sh if [ $# -lt 2 ] ; then echo "Usage: prg xx xx" elif [ $# -gt 2 ] ; then echo " 2 " # before=$1 after=$2 list= ls -1./ for le in $list #$le if [ $le!= basename $le.$before ] ; then newle= basename $le.$before.$after mv $le $newle ne [j05002@mymv]% ls mymv.sh* mymv.sh~* sample1.eps sample2.eps [j05002@mymv]% sh mymv.sh eps ps [j05002@mymv]% ls mymv.sh* mymv.sh~* sample1.ps sample2.ps 1. basename,.,,,. 2. $le. if $le!= `basename $le.$before `. basename $le.$befor, $le $before $le., $le, $le,,. 6
(3) Level 3 -thumbnail4.sh- #!/bin/sh # le : thumnail4.sh # syonopsis: thumnail4.sh SUFFIX photo_num # comment : SUFFIX # 1 photo_num # HTML # if [ $# -lt 3 ] ; then echo "Usage: $0 SUFFIX photo_num" echo " RESIZE: percent" echo " example) thumnail3.sh jpg 30 2" # SUFFIX=$1 RESIZE=$2 photo_num=$3 les= ls *.$SUFFIX count=0 # # ## DIR=resized if [ -d $DIR ] ; then echo " temporal directory ($DIR) exsits..." else mkdir $DIR echo " temporal directory ($DIR) CREATED." ## cd $DIR for lename in $les convert -resize $RESIZE%x$RESIZE%../$lename ${lename}_s.$suffix echo "convert $lename to $DIR/${lename}_s.$SUFFIX" count= expr $count + 1 ne cd.. page_count=1 #HTML flag=1 #HTML photo_count=1 # resized_les= ls $DIR/*_s.$SUFFIX for lename in $resized_les if [ $flag -eq 1 ] ; then # HTML ## HTML echo "<html>" > page$page_count.html echo "<head>" >> page$page_count.html echo "<title>thumbnail page$page_count</title>" >> page$page_count.html echo "</head>" >> page$page_count.html echo "<body>" >> page$page_count.html flag=0 7
-thumbnail4.sh- echo "<img src=\"$lename\">" >> page$page_count.html # if [ $photo_count -eq expr $photo_num \* $page_count -o $photo_count -eq $count ] ; then flag=1 if [ $flag -eq 1 ] ; then ## HTML echo "</body>" >> page$page_count.html echo "</html>" >> page$page_count.html echo "page$page_count is made" page_count= expr $page_count + 1 photo_count= expr $photo_count + 1 ne [j05002@thumbnail]% sh thumbnail4.sh jpg 40 5 temporal directory (resized) exsits... convert DSC00030.jpg to resized/dsc00030.jpg_s.jpg convert DSC00057.jpg to resized/dsc00057.jpg_s.jpg convert DSC00076.jpg to resized/dsc00076.jpg_s.jpg convert DSC00149.jpg to resized/dsc00149.jpg_s.jpg convert DSC00160.jpg to resized/dsc00160.jpg_s.jpg convert DSC00204.jpg to resized/dsc00204.jpg_s.jpg page1 is made page2 is made [j05002@thumbnail]% cat page1.html <html> <head> <title>thumbnail page1</title> </head> <body> <img src="resized/dsc00030.jpg_s.jpg"> <img src="resized/dsc00057.jpg_s.jpg"> <img src="resized/dsc00076.jpg_s.jpg"> <img src="resized/dsc00149.jpg_s.jpg"> <img src="resized/dsc00160.jpg_s.jpg"> </body> </html> [j05002@thumbnail]% cat page2.html <html> <head> <title>thumbnail page2</title> </head> <body> <img src="resized/dsc00204.jpg_s.jpg"> </body> </html> 1. flag, HTML,, HTML. 8
(4) Level 4.1 & Level4.2 & Level 4.3 #!/bin/sh # if [ $# -lt 1 ] ; then echo " " elif [ $# -gt 1 ] ; then echo " 1 " # if [! -e $1 ] ; then echo "$1 " # if [! -f $1 ] ; then echo "$1 " #Level4.1 echo -n " " echo less $1 wc -l echo "" #Level4.2 echo " " cut -d -f 4 $1 tr -d [ cut -d : -f 1 uniq -c echo "" #Level4.2 IP echo "IP " cut -d -f 1 $1 sort uniq -c echo "" #Level 4.3 ##Level4.2 ## "daily.data" daily= cut -d -f 4 $1 tr -d [ cut -d : -f 1 uniq -c echo " " > daily.data flag=1 for daily in $daily if [ $flag -eq 1 ] ; then data=$daily flag=0 else echo "$daily $data" >> daily.data flag=1 ne # gnuplot PLOT=daily.gnuplot echo "set terminal postscript eps" > $PLOT echo "set output \"daily.eps\"" >> $PLOT echo "set xdata time" >> $PLOT echo "set timefmt \"%d/%b/%y\"" >> $PLOT echo "plot \"daily.data\" using 1:2 notitle with boxes" >> $PLOT gnuplot < $PLOT 9
[j05002@log]% sh count.sh access_log 95 7 06/Dec/2004 1 08/Dec/2004 76 09/Dec/2004 2 10/Dec/2004 1 13/Dec/2004 2 15/Dec/2004 1 17/Dec/2004 2 21/Dec/2004 3 22/Dec/2004 IP 1 133.13.48.235 1 133.13.48.8 1 133.13.49.18 2 133.13.50.76 1 133.13.52.37 1 133.13.53.122 2 133.13.54.156 2 133.13.54.53 3 133.13.57.226 2 133.95.109.80 1 210.139.250.215 1 210.47.27.36 1 218.113.200.138 1 218.146.238.174 1 219.160.252.142 5 219.166.179.56 3 220.109.8.237 5 220.110.222.75 3 220.20.70.41 1 220.221.238.133 2 220.221.239.196 1 35.10.47.37 3 60.34.136.173 1 61.116.186.45 2 61.199.170.156 1 61.213.47.211 6 61.78.61.166 1 61.95.54.174 1 64.53.90.33 2 66.196.90.178 1 66.196.90.207 5 66.196.90.59 1 66.196.90.92 1 66.196.91.132 1 66.196.91.175 1 66.196.91.178 1 66.196.91.199 1 66.196.91.202 1 66.196.91.203 2 66.196.91.205 1 66.196.91.206 2 66.196.91.207 2 66.196.91.216 7 66.196.91.239 1 66.196.91.32 1 66.196.91.87 1 68.121.94.147 1 68.143.54.82 4 82.67.110.170 2 82.79.189.243 10
1:!*"!)"!("! "!&"!%"!$"!#"!" #$+" #$+") #$+"- #$+## #$+#% #$+# #$+#) #$+#- #$+$# #$+$% 1. wc,,.. 2. cut.,,,,. 3.. access_log. 64.53.90.33 - - [17/Dec/2004:10:39:15 +0900], cut -d -f 4 $1 ( ),.. [17/Dec/2004:10:39:15+0900] tr -d [ [.. 17/Dec/2004:10:39:15 +0900] 11
cut -d : -f 1 : ( ),.. 17/Dec/2004, uniq -c,. 3,.,.,,.,. [1] Linux[Linux ] http://homepage2.nifty.com/cs/linux command/command/index.html [2] -[ & Tips] http://www.rhythm-cafe.com/shell/grammermenu.aspx 12