INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

something wrong in the AWK code...

something wrong in the AWK code...

(OP)
Hi,
I trying to find a bug in the code below:


FILE:

A00|1|1|1|1|1|1|1|FI|0
A01|0|1|1
FPV|1
FPV|2
FPV|3
FSV|1
FPT|2
HNH|0

AWK:

BEGIN {FS="|"}
{
if ( $1=="A00" ){
if ( $9=="FI" ) {
getline
if ( $1=="A01" ) {getline; printf "A01 " FNR "\n"} else {printf "problem: " FNR "\n"; exit}
if ( $1=="FPV" ) {
printf "poszlo w FPV \n";
while ($1!="FSV") {
if ( $1=="FPV" ) { getline; printf "poszlo w FPV2 " FNR "\n" ; }
else {printf "problem: " FNR $1"\n"; exit}}
}
if ( $1=="FSV" ) {prinft FNR " RR \n"; }
else {printf "problem: " FNR $1"\n";}
printf FNR " wiersz odczytany " $1 "\n"
}
else printf "problem: " FNR "\n"
}
}
END {}

when awk left the while loop then something goes wrong.

THX 4 help!
Cynki

RE: something wrong in the AWK code...

Hi

Please help us to help you by providing more readable question :
  • Post code between [code] .. [/code] TGML tags.
  • Post preformatted text between [pre] .. [/pre] TGML tags.
  • Explain what you mean by "something goes wrong"
  • Explain what should happen when everything goes well
By the way, that "prinft" in the code is there for real, or just a typo when posting here ?

Feherke.
feherke.ga

RE: something wrong in the AWK code...

(OP)
Ok,
I work with thats matter but I have different problem:

if ( $1=="FNR" ) getline else exit;

but the FNR is a string in the opened file not as a variable in this case.

any ideas? :)

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close