當前位置:編程學習大全網 - 網站源碼 - 編寫壹個shell腳本,腳本名為shell,執行該腳本的功能是:判斷第壹個位置參數是否是

編寫壹個shell腳本,腳本名為shell,執行該腳本的功能是:判斷第壹個位置參數是否是

#!/bin/bash

if?[?$#?-lt?1?];then

echo?"usage?$0?[path?or?file]"

exit?-1

fi

if?[?"$1"?=?"/root"?];then

ls?-a?$1?|?tee?13out?

else

echo?"第壹個位置參數不是/root目錄!"

exit?-2

fi

argc=0

for?i?in?$@

do

argc=$(($argc+1))

if?[?$argc?-eq?1?];then

continue

fi

if?[?-f?$i?];then

echo?"$i?的文件內容:"?|?tee?-a?13out

cat?$i?|?tee?-a?13out

elif?[?-d?$i?];then

echo?"$i?為目錄文件"

else

echo?"$i?既不是普通文件也不是目錄文件"

fi?

done

  • 上一篇:求傳奇手遊排名,有哪些比較推薦的?
  • 下一篇:如何處理c語言
  • copyright 2024編程學習大全網