我正在編寫一個bash腳本來下載imgur相冊或學習bash。我有這麼多的書面,但當我運行它我得到這個輸出:Bash腳本「命令未找到錯誤」
Enter the URL of the imgur album you would like to download: imgur.com
./imgur_dl.sh: line 25: Validating: command not found
./imgur_dl.sh: line 26: Getting: command not found
./imgur_dl.sh: line 30: imgur.com: command not found
這是我的代碼到目前爲止。
#!/bin/bash
url=""
id=""
get_id(){
echo "Getting Album ID..."
local url=$1
echo $url
echo "Successflly got Album ID..."
return
}
validate_input(){
echo "Validating Input..."
local id=$1
echo $id
echo "Input Validated Successfully..."
return
}
get_input(){
read -p "Enter the URL of the imgur album you would like to download: " url
echo $url
$(validate_input url)
$(get_id url)
return
}
$(get_input)
我在做什麼錯,或者我沒有得到什麼? 我在macOS上工作,它有所幫助。
參見[命令替換(https://en.wikipedia.org/wiki/Command_substitution)。 – nobar