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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FORMATTING A FILE IN 4 COLUMNS

Status
Not open for further replies.

maguy

Technical User
Sep 17, 2002
4
FR
Bonjour,

Premierement je vous remercie pour l'aide.

A l'execution j'ai eu une erreur . Vous trouverez ci joint une copie d'ecran :
thomas<SRD>$ awk '
> BEGIN{FS="|";OFS="\t"}
> NF==8{r=(NR % 4);for(i=1;i<=8;++i)a[r,i]=$i}
> !r{for(i=1;i<=8;++i)if(i!=6)print a[1,i],a[2,i],a[3,i],a[0,i];delete a}
> END{if(r)for(i=1;i<=8;++i)if(i!=6)print a[1,i],a[2,i],a[3,i],a[0,i]}
> ' cdi.txt > mag.txt
syntax error The source line is 4.
The error context is
!r{for(i=1;i<=8;++i)if(i!=6)print a[1,i],a[2,i],a[3,i],a[0,i];de
lete >>> a} <<<
awk: The statement cannot be correctly parsed.
The source line is 4.
awk: The statement cannot be correctly parsed.
The source line is 5.

Je ne connais rien ni en awk ni en shell.

J 'ai besoin absolument votre aide pour formatter mon fichier en fichier etiquette.
Merci encore

Maguy
 
Try nawk instead of awk.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
And this ?
awk '
BEGIN{FS="|";OFS="\t"}
NF==8{r=(NR % 4);for(i=1;i<=8;++i)a[r,i]=$i}
!r{for(i=1;i<=8;++i){
if(i!=6)print a[1,i],a[2,i],a[3,i],a[0,i]
for(j=0;j<=4;++j)a[j,i]=""
} }
END{if(r)for(i=1;i<=8;++i)if(i!=6)print a[1,i],a[2,i],a[3,i],a[0,i]}
' cdi.txt > mag.txt

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top