作业社区
探索学习新天地,共享知识资源!
Linkus 的学生作业:
#! /bin/bash echo "练习1" array=(7 5 6 3 2) i=0 for val in ${array[@]} do echo "array[$i] = ${array[$i]}" i=`expr $i + 1` done echo "练习2" array=(I am westos teacher welcome to westos training class) i=0 for word in ${array[@]} do #echo "$word" len=${#array[$i]} if [ $len -le 6 ] then echo "$i:$word" fi i=`expr $i + 1` done
+9
Linkus 的学生作业:
#! /bin/bash echo "练习1" PARAM_NUM=$# echo "PARAM_NUM: $PARAM_NUM" if [ $PARAM_NUM -eq 2 ] then i=1 while [ $i -le $2 ] do touch ./"$1_$i.txt" i=`expr $i + 1` done elif [ $PARAM_NUM -eq 1 ] then i=1 while [ $i -le 5 ] do touch ./"$1_$i.txt" i=`expr $i + 1` done elif [ $PARAM_NUM -eq 0 ] then rm *.txt fi #! /bin/bash echo "练习2" echo "Input PATH: $1" if [ -d $1 ] then FILES=`ls $1` #echo "$FILES" CNT=0 for FILE in $FILES do echo "FILE: $FILE" if [ -d $1/$FILE -o -f $1/$FILE ] then CNT=`expr $CNT + 1` fi done echo "There are $CNT files under $1." else echo "Not Directory." fi
+10