我們用各種格式來撰寫一個複合的條件式程式碼,讀者可以 觀摩各種增加程式可讀性的技巧。
for file 
do 
   if test -f $file
   then
      if  test -r $file
      then 
	 if test -x $file
	 then
	    echo "File $file is 
            readable and executable"
	 fi
      fi
   fi
done
for file 
do 
   if [ -f $file ]
   then
      if  [ -r $file ]
      then 
	 if [ -x $file ]
	 then
	    echo "File $file is 
            readable and executable"
	 fi
      fi
   fi
done
for file 
do 
   if [ -f $file -a -r $file  -a -x $file ]
   then 
       echo File $file is readable and executable
   fi
done
 
for file 
do 
[ -f $file -a -r $file  -a -x $file ] && echo File $file is readable and executable
done
Web Page Copyright: 亞洲大學資訊電機學院 連耀南 yaonanlien@asia.edu.tw  ifexample2.htm,  Sun Dec 14 23:14:48 CST 2025