The scenario is a value drops from A to B or A to C or B to C.
If it drops from A to B or B to C, we print "Drop one level"
If it drops from A to C, we print "Dropped two levels".
The problem is script is throwing error when comparing variable values.
A test script is shown below:
If I remove the last comparison after the "||" sign the script works!
I have tried troubleshooting, but not getting it right.
Can anyone help me?
Last edited by pludi; 12-16-2009 at 02:19 AM..
Reason: code
I need some help which would probably be for most of you a simple script.
I need to read in the data from a .dat file and then compare avg to see who is the highest avg. Here is my script so far.
#!/bin/ksh
#reading in the data from lab3.dat
filename=$1
while read name o1 o2 o3 o4 o5 o6... (0 Replies)
Hello,
I am trying to compare two variables, which both have a word stored in it.
The code I am using is. Please tell me which one of these is correct.Or please tell me the correct syntax.
Thankyou
if then
if then
if then
if then
if then
None of them seems to work... (3 Replies)
hi,
I want to compare i variable in the awk statement but its not working out. Pl help me out
If we do the comparison like this its OK,
cat sample | awk -F" ", '{if ($1=="1-Sep-2009") print $1,$2,$3,$4,$5}'
But if u use a variable instead of "1-Sept-2009", it does not return anything,... (2 Replies)
Hi all,
I have a variable say var1 (output from somewhere, which I can't change)which store something like this:
echo $var1
name=fred
age=25
address="123 abc"
password=pass1234
how can I make the variable $name, $age, $address and $password contain the info?
I mean do this in a... (1 Reply)
Hi all,
How I could compare variable and regexp?
For example...
I am running the script ./aaa.sh -b *
* is variable $2 (second argument of script).
I would compare variables $a (generated from my cycle) and $2 as regexp.
I need from regular expression find file that satisfies this regexp.... (1 Reply)
So, I'm making a little awk script that generates a range-based histogram of a set of numbers. I've stumbled onto a strange thing. Toward the end of the process, I have this test:
if ( bindex < s )
"bindex" is the "index" of my "bin" (the array element that gets incremented whenever a... (2 Replies)
Hi All,
I want to compare the variable value with string in a shell script.
my code is:
for var in $packsName
do
if
then
echo $var
fi
done
But I am getting error as:
ABC : not found.
Am I going wrong somwhere?
please guide.
Thanks. (5 Replies)
Hello folks,
I have two files, which have usernames, I want to see the contents of file1.txt which is missing in file2.txt and another comparison file2.txt contents which is missing in file1.txt. please suggest.
file1.txt
user
u2
u8
a9
p9
p3
u4
z8
aaa
ahe
oktlo (7 Replies)
Hi , Need help, p
for value in `awk -F, '{print $1 }' ad | uniq`
do
x=$(echo $value)
echo $x
echo `awk -F, '{if( $1 == $x) sum = sum + $8 } END{print sum}' ad` --- not working
echo `awk -F, '{if($1 == “MT”) sum = sum + $8 } END{print sum}' ad` -- Working but hard coded
done;
ad... (4 Replies)