开发者

Divert a value in Shell Script

开发者 https://www.devze.com 2023-03-19 01:54 出处:网络
I have the following code but I didn\'t understand the [ $val -eq 0 ] 2 part. What does the two (2) there for?

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

精彩评论

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