Supreetha
Supreetha

Reputation: 21

variable is not getting set to AMER

Below is the code :

if [ "$p_geo_code" = S America ]; then   
'$p_geo_code'=AMER; fi

Unable to get the value as AMER instead getting 'S America'. can you let me know where i am going wrong,

Upvotes: 0

Views: 20

Answers (1)

git-bruh
git-bruh

Reputation: 333

Comparison with a multi-word string should be in quotes otherwise the shell won't know what you're asking it to compare, and variable assignment does not use the $ symbol, just the variable name:

if [ "$p_geo_code" = "S America" ]; then
    p_geo_code=AMER
fi

Upvotes: 2

Related Questions