04-19-2005
it seems to me the error here is from the multiple line result of the awk test ... maybe if awk tested for NF per each line this could work ...
Quote:
Originally Posted by rkumar28
Thanks for lot for replying so soon on this.
I changed the awk statement and the "if" statement as suggested:
#c=`awk -F"|" '{ print NF }' test`
c=$(awk -F"|" '{ print NF }' test)
echo "c is $c"
#if [ c > 2 ]
if [ "$c" -gt "2" ]
then
echo "Inside if"
else
echo "else part"
fi
I get the error below:
c is 2
2
2
2
2
[: 2
2
2
2
2: bad number
else part
9 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
suppose a name is read
how to check whether the name contains only alphabets and space
not non-alphabetic characters and special characters (5 Replies)
Discussion started by: manisha_agrawal
5 Replies
2. Shell Programming and Scripting
Hi friends, :)
In a shell script i found the following if condition.
echo -n "Which version of $1 do you want to restore ('0' to quit)? : "
read desired
if ${desired:=1} -ge $index ] ; then
echo "$0: Restore canceled by user: index value too big." >&2
exit 1
fi
Can... (1 Reply)
Discussion started by: ravi raj kumar
1 Replies
3. Shell Programming and Scripting
Hi
how to write this:
if
then
usage
fi
thx (3 Replies)
Discussion started by: melanie_pfefer
3 Replies
4. Shell Programming and Scripting
Hi All ,,
This is my code .. i am checcking a file temp66.txt , when i execute this
shell it checks whether the file is 0 byte file or not ..
if it is a 0 byte file , then Program exists out else it Prints the Echo Statement ..
if then
RET_CODE=$?
if then
echo 'File... (18 Replies)
Discussion started by: raghav1982
18 Replies
5. Shell Programming and Scripting
Hi
I have to evaluate multiple conditions with an 'or'.
Here is an example:
if
when i use the above i get a error message
'
Please help me to know if i am missing something in the syntax.
how do i achieve multiple "or" in the same if condition.
Thanks. (11 Replies)
Discussion started by: sunrexstar
11 Replies
6. HP-UX
Executed the following if conditions .. and got different results .
only (( )) gave correct o/p with all scenarios .
Can anybody please let me know what is the difference between and ] and ((condition)) when used with if condition.
And why each condition gave different result.
1.... (2 Replies)
Discussion started by: soumyabubun
2 Replies
7. Shell Programming and Scripting
hi,
I have some problems in my simple script about the redirect echo stdout command inside a condition. Why is the echo command inside the elif still execute in the else command
Here are my simple script
After check on the two diff output the echo stdout redirect is present in two diff... (3 Replies)
Discussion started by: jao_madn
3 Replies
8. Shell Programming and Scripting
HI
My doubt may be basic one but I need to get it clarified..
When i use "if" condition that checks for many AND, OR logical conditions
like
if ]; then
return 0
fi
Even the if condition fails it returns as zero.. Any clue..
But if i add else condition like
if ]; ... (2 Replies)
Discussion started by: Priya Amaresh
2 Replies
9. UNIX for Dummies Questions & Answers
Hi all
Unix newbie - please be gentle
Am modifying an existing script to error trap a variable with a length of 0
#!/bin/bash
ipfile='/var/data/bin/ipaddress'
] && ipold="$(< "$ipfile" )"
ipnew="$( wget -q -O - checkip.dyndns.org | sed -e 's/.*Current IP Address: //;s/<.*$//' )"
#... (6 Replies)
Discussion started by: CRChamberlain
6 Replies