判斷鏈接文件,返回結果是普通文件,求解答!#!/bin/bash#判斷輸入的是什么文件read -t 30 -p "input filename:" file#判斷輸入內容是否為空if [ -z "$file" ]? ? ? ? then? ? ? ? ? ? ? ? echo "filename is null"#為空退出腳本,返回錯誤代碼0 ? ? ? ? ? ?? ? ? ? ? ? ? ? exit 0#判斷輸入文件是否不存在elif [ ! -e "$file" ]? ? ? ? then? ? ? ? ? ? ? ? echo "file is non-existent"#不存在退出腳本,返回錯誤代碼1? ? ? ? ? ? ? ? exit 1#判斷是不是普通文件elif [ -f "$file" ]? ? ? ? then? ? ? ? ? ? ? ? echo "$file is general file"#判斷是不是目錄文件elif [ -d "$file" ]? ? ? ? then? ? ? ? ? ? ? ? echo "$file is directory"#判斷是不是鏈接文件elif [ -L "$file" ]? ? ? ? then? ? ? ? ? ? ? ? echo "$file is link file"else? ? ? ? echo "$file is other file"fi
- 1 回答
- 0 關注
- 1510 瀏覽
添加回答
舉報
0/150
提交
取消