我從昨天開始學習shell腳本。我想製作一個腳本,用於從文本文件中的所有數字中返回最小數字。這是我迄今爲止:Shell腳本新手:「找不到命令」
#!/bin/bash
file="example.txt"
min=cat $file|head -1
for i in $(cat $file); do
if [[ $min -gt $i ]]; then
min=$i
fi
done
echo $min
我不斷收到第3行錯誤,說「example.txt:command not found」。
這應該讓你開始:https://stackoverflow.com/questions/9449778/what-is-the-benefit-of-using-instead-of-backticks-in-shell-scripts – fvu
笑着。 ..堅持下去,你會很快與你的外殼交朋友。您需要將[** Bash Guide **](http://mywiki.wooledge.org/BashGuide),[** Bash FAQ **](http://mywiki.wooledge.org/BashFAQ)和[ ** Bash Pitfalls **](http://mywiki.wooledge.org/BashPitfalls)。每個人都可以找到豐富的信息。 –