Computing.Net > Forums > Unix > awk help for the

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

awk help for the

Reply to Message Icon

Name: htnkd
Date: July 9, 2004 at 11:33:49 Pacific
OS: linux
CPU/Ram: ?
Comment:

having problem with unix on the if else statement

what I want to do is look at a "|" file with around 10000 records. If it matches a line change a field , if it doesn't move on to the next one

here is what I have

gawk -F "|" '{ if (($7) < 5000) $7 = "9" }
elseif {($7) == 4999 - 25000 $7 = "8" }
elseif {($7) == 24999 - 50000 $7 = "7"}
{print $0}' OFS="|" test.txt > a

what I get is only the first runs through but does not continue.
I need it to look at each line if it matches overwrite it and make the change if it does not keep it the same and continue to the next search for the match-- print out all the changes and non changes into the final file

Thanks



Sponsored Link
Ads by Google

Response Number 1
Name: nails
Date: July 10, 2004 at 00:52:26 Pacific
Reply:

Hi:

I think you have the else if syntax incorrect. It should be:

if conditional
then
.
elif
then
.
else
fi


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: awk help for the

Need awk help for class www.computing.net/answers/unix/need-awk-help-for-class/5582.html

Sed or Awk help www.computing.net/answers/unix/sed-or-awk-help/6447.html

AWK help!!! (re: records & conditio www.computing.net/answers/unix/awk-help-re-records-amp-conditio/4454.html