开发者

Divert a value in Shell Script

I have the following code but I didn't understand

the [ $val -eq 0 ] 2 part. What does the two (2) there for?

#!/bin/bash 
val=0 
while [ $val -eq 0 ] 2> /dev/null; do 
    read -p "Please enter a value:开发者_如何转开发 " val 
done 
echo "You didn't enter 0!" 

Cheers,


It means standard error, i.e. redirect any error message to /dev/null which basically means don't display any error message that would show up in the redirected command.


What does the two (2) there for?

2 means stderr stream

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜