1. 下面给出了一个SHELL程序,试对其行后有#(n)形式的语句进行解释,并说明程序完成的功能。 #!/bin/bash #(1) dir=$1 #(2) if [ -d $dir ] #(3) then cd $dir #(4) for file in * do if [-f $file ] #(5) then cat $file #(6) echo “end of file $file” fi done else echo “bad directory name $dir” fi
#!/bin/sh read max min=$max sum=$max i=1 while [$i –lt 100] do read x sum=`expr $sum + $x` if [ $max –lt $x ] then max=$x fi if [ $ x –lt $min ] then min=$x fi i=`expr $i + 1` done echo "sum = $sum ; max = $max min = $min "