シェルrun.shで私は持っています
find . -name "*.txt" -exec grep -H SNR {} \; | grep "$1" > result.txt
if[ "$1" -eq "offs0.5"]
then
fi
私が入力した場合:run.sh offs0.5
このエラー:
[: offs0.5 : 整数式が必要です
文字列比較を行うには、次のようなものを使用する必要があります。
[ "$1" == "offs0.5" ]
eq
文字列を比較している間、式 with は算術比較を探していることに注意してください。
また、あなたの表現には
if[ "$1" -eq "offs0.5"]
^^^ ^ needed space
no eq on string comparison
$ d="offs0.5"
$
$ [ "$d" == "offs0.5" ] && echo "yes"
yes
$ d="offs0.5aa"
$ [ "$d" == "offs0.5" ] && echo "yes"