for DEMO
举例一:
[xiluhua@vm-xiluhua][~/shell_script]$ cat forDemo1.sh #======================================================================================= #/bin/bash #auth: xiluhua #date: 20160717 #desc: print file list in a directory #======================================================================================= [ -z $1 ] && echo "exception@1: directory can not be null" && exit 1 echo "prompt: print file list in a directory ..." for file in $(ls $1/*.123) do echo $file done exit 0
举例二:
[xiluhua@vm-xiluhua][~/shell_script]$ cat forDemo2.sh #======================================================================================= #/bin/bash #auth: xiluhua #date: 20160717 #desc: print triangle with * #======================================================================================= for (( i=0; i<3; i++ )) do let space=2-$i #echo $space for (( j=0; j<${space}; j++ )) do printf " " done let star=2*$i+1 for (( k=0; k<$star; k++ )) do printf "*" done echo "" done