0
我在遇到問題時需要將腳本作爲命令行參數運行,測試是否存在,然後切換到該路徑以執行工作。在這裏我嘗試:目錄命令行參數
#!/bin/bash
scriptpath=$1
if [ $# -lt 1 ]
then
echo "Usage: script.sh <directory_name>"
fi
if [ -d scriptpath ]
then
# work......
else
echo "Directory does not exist"
fi
而你的問題是......? – 2012-08-10 21:24:28
它不起作用... – 2012-08-10 21:24:52
即使目錄存在流下降到else語句 – 2012-08-10 21:26:19