沒有該文件則創建,有則 ls -l 輸出文件信息。
#!/bin/bash echo "enter the name:" read filename if test -e $filename ; then ls -l $filename else touch $filename fi
輸出
enter the name: sss.sh -rwxr-xr-x 1 root root 147 Dec 3 09:02 sss.sh
沒有該文件則創建,有則 ls -l 輸出文件信息。
#!/bin/bash echo "enter the name:" read filename if test -e $filename ; then ls -l $filename else touch $filename fi
輸出
enter the name: sss.sh -rwxr-xr-x 1 root root 147 Dec 3 09:02 sss.sh
本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。