开发者

grep output different on two servers

I am trying to create a s开发者_Python百科cript, and one part requires showing lines with numeric values.

My basic syntax is:

echo $i | grep [0-9]

For example, I set i=12345, it should output 12345.

But on one server, it doesn't output anything (exactly the same commands).

I do not know how to Google this issue, I have tried "grep output different on other server", to no avail.


When using a regexp, either use egrep or grep -e to make sure the pattern is not treated as a plain string.


maybe it's a shell issue? some shells interpert [] differently try

echo "1234" | grep "[0-9]"

(with quotes)

also try

grep --version

to see if there is a different grep version

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜