Dean
Dean

Reputation: 1153

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,

Upvotes: 0

Views: 106

Answers (2)

jlliagre
jlliagre

Reputation: 30823

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.

Upvotes: 3

Prince John Wesley
Prince John Wesley

Reputation: 63698

What does the two (2) there for?

2 means stderr stream

Upvotes: 1

Related Questions