|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Echo not displaying variable in If-Else condition
Code:
if [ "${x_oug}" -ne 0 ]
then
echo "Entry Valid : ${x_oug}"
else
echo "Entry Invalid : " 0
fiIn the above code the 3rd line is not working... it does not print anything I tried following as well .. but no luck! Code:
echo "Entry Valid : ${x_oug}"
echo "Entry Valid : " ${x_oug}
echo "Entry Valid : $x_oug
echo "Entry Valid : " "${x_oug}"However, if I put a constant like following it works correctly Code:
echo "Entry valid : 5 " In fact I am forced to use if else as echo not prinitng the variable when it has 0 value Please help me on this Thanks and Regards Chetanz |
| Sponsored Links | ||
|
|
#2
|
|||
|
|||
|
How are you setting x_oug?
|
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
What's the value of
x_oug ? How do you assign it? Did you run the script with the xtrace option set?
|
|
#4
|
|||
|
|||
|
Thanks for quick replies I am retriving it from a file which is in fact output of vmstat... eliminating header, awking a particular column values and then getting max of that to set x_oug Code:
x_oug=`cat /u01/zopepx/vmstat1.txt|grep -v kthr|grep -v '-'|grep -v r|awk '{print x7}'|grep -Ev '(#.*$)|(^$)'|grep -v System|awk '{if($1>mx)mx=$1;}END{print mx}'`Regards Chetanz |
| Sponsored Links | |
|
|
#5
|
|||
|
|||
|
You know you can make THAT statement way more legible and efficient?
Pls post output of echo "$x_oug" |
| Sponsored Links | |
|
|
#6
|
|||
|
|||
|
Hello Output remains as following i.d. NULL Code:
Entry valid : Regards Chetanz |
| Sponsored Links | |
|
|
#7
|
|||
|
|||
|
Quote:
|
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Displaying contents with Echo | sathyaonnuix | UNIX for Dummies Questions & Answers | 3 | 09-04-2012 06:08 AM |
| echo the NAME of the variable | ajp7701 | Shell Programming and Scripting | 5 | 04-25-2012 06:57 PM |
| redirect stdout echo command in condition A run in condition B | jao_madn | Shell Programming and Scripting | 3 | 11-02-2011 09:01 PM |
| Variable not displaying while running in cron job | josephroyal | Shell Programming and Scripting | 4 | 06-22-2011 06:52 AM |
| multiple echo statements in if condition | wizardofoz | Shell Programming and Scripting | 2 | 03-12-2011 03:00 PM |
|
|