Registered User
Registered User

Reputation: 5371

integer expression expected testing or condition in if else bash scripts

In a shell script I wrote following lines gave error during execution of script

if [ p -eq 35 -o p -eq 70 ]; then
echo "Sleeping ....zzz ........zzzz......."
sleep 5

get following error

/d2.sh: line 6: [: p: integer expression expected

Upvotes: 1

Views: 8836

Answers (1)

Sven Marnach
Sven Marnach

Reputation: 602625

You probably want $p instead of p:

if [ $p -eq 35 -o $p -eq 70 ]; then
    ...

Upvotes: 2

Related Questions