shell 程序之遍歷目錄

取當前路徑
currentpath = $PWD
 
遍歷根目錄
for file in /*
  do
  if test -f $file
  then
    echo 是文件
  fi
  if test -d $file
  then
    echo 是目錄
  fi
  if test -x $file
  then
    echo 可執行
  fi
  if test -w $file
  then
    echo 可寫
  fi
  echo $file
done
 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章