Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

something wrong in the AWK code...

Status
Not open for further replies.

Cynki

Programmer
Jun 11, 2015
2
PL
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
 
Hi

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

Feherke.
feherke.ga
 
Anyway this line if ( $1=="FPV" ) is never reached.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
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? :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top