Computing.Net > Forums > Unix > awking a file

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.

awking a file

Reply to Message Icon

Name: Junes
Date: November 4, 2005 at 02:27:50 Pacific
OS: Unix
CPU/Ram: Solaris
Comment:

I have written a script to awk a file, which beings with STATUS_MESSAGE and read a parameter $STCODE. It should read the second column in the text file i.e. ^1$ and if it meets the condition read the message “See BOA-NBU-1. Partial success”. But I am finding that I am getting an awk failure. Can someone offer some advice!!

AWK COMMAND
=============

# `awk < nberrors_rules.txt '/^STATUS_MESSAGE / && '$STCODE' ~ $2 '`
awk: syntax error near line 1
awk: bailing out near line 1

TEXT FILE - nberrors_rules.txt
========================

STATUS_MESSAGE ^1$ See BOA-NBU-1. Partial success.
STATUS_MESSAGE ^(56|58)$ See BOA-NBU-2. Network problems.
.........

King Regards

Junes



Sponsored Link
Ads by Google

Response Number 1
Name: desanti
Date: November 5, 2005 at 06:33:13 Pacific
Reply:

Hi: if your using a file to give awk commands
you need to use awk -f(filename of commands).

santi


0

Response Number 2
Name: Junes
Date: November 7, 2005 at 04:11:44 Pacific
Reply:

If i try the -f option for awk, i get the "awk: can't open " error message
The following awk statement works fine without the -f option
`awk <$RULES '/^IGNORE_POLICY / { print $2 }'`

Below how i turned on debugging to show what is happening, can someone provide me with some advice!!!!


$RULES = /home/nberrors_rules_jm_NEW.txt_TEST
$2 = ^219$ of the following (STATUS_MESSAGE ^219$ See BOA-NBU-1. Partial success)


MESSAGE=`awk <$RULES '/^STATUS_MESSAGE / && '$STCODE' ~ $2 { for(a=3;a<NF+1;a++) { printf "%s ",$a }}'`
...........
+ + awk /^STATUS_MESSAGE / && 219 ~ $2 { for(a=3;a<NF+1;a++) { printf "%s ",$a }}
+ 0< /home/nberrors_rules_jm_NEW.txt_TEST
awk: syntax error near line 1
awk: bailing out near line 1
MESSAGE=


STCODE_POL_MESSAGE=`awk <$RULES '/^STATUS_MESSAGE_POLICY / && '$STCODE' ~ $2 && toupper("'$POLICY'") ~ toupper($3) { for(a=4;a<NF+1;a++) { printf "%s ",$a }}'`
...........
+ + awk /^STATUS_MESSAGE_POLICY / && 219 ~ $2 && toupper("emacromsq14") ~ toupper($3) { for(a=4;a<NF+1;a++) { printf "%s ",$a }}
+ 0< /home/nberrors_rules_jm_NEW.txt_TEST
awk: syntax error near line 1
awk: bailing out near line 1
STCODE_POL_MESSAGE=


King Regards

Junes


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


sed scripting question sed to find and add lines



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: awking a file

Editing a file without awk or sed www.computing.net/answers/unix/editing-a-file-without-awk-or-sed/5437.html

replace data in a file www.computing.net/answers/unix/replace-data-in-a-file/6189.html

deleting rows in a file www.computing.net/answers/unix/deleting-rows-in-a-file/3676.html