を実行するとき./test.sh 12.34
、grepは一致する必要が12.34
あり12-34
ます。これはどのように達成できますか?
#!/bin/sh
ip=$1
echo $ip
if netstat | grep ssh | grep $ip; then
netstat | grep ssh | grep $ip
else
echo 'No'
fi
あなたは使うことができgrep
て-F
オプション:
man grepから:
-F, --fixed-strings
Interpret pattern as a set of fixed strings (i.e. force grep to
behave as fgrep).
あなたの例:
grep -F "$ip"
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加