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

exctract file according header,column and row

Status
Not open for further replies.

toax

Programmer
Jun 23, 2011
5
DE
I am beginer in programing with awk, I have file 1 :

1 2 3
3 3 3 3 3 3 2 3
4 4 4 4 4 4 1 4
7 7 6
5 5 5 5 5 5 5 5
6 6 6 6 6 6 6 6
7 7 7 7 7 7 7 7
3 4 2
1 1 1 1 1 1 1 5
2 2 2 2 2 2 2 3
4 4 4 4 4 4 4 4
6 6 6 6 6 6 6 6

and I would like to extract file 1 according header, row and coloumn. This file will generete file 2 , file 3 and file 4 :

File 2 :
3 3 3 3 3 3 2 3
4 4 4 4 4 4 1 4

File 3 :
5 5 5 5 5 5 5 5
6 6 6 6 6 6 6 6
7 7 7 7 7 7 7 7

File 4 :
1 1 1 1 1 1 1 5
2 2 2 2 2 2 2 3
4 4 4 4 4 4 4 4
6 6 6 6 6 6 6 6

is it possible to do with awk ?
Thanks in advance



 
A starting point:
Code:
awk 'BEGIN{seq=1}NF==3{out="file"(++seq);next}{print >out}' file1

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks for your reply, but this code only produce one file ("file"), isn't? the problem is I want to produce saveral files (file 2 , 3, and 4) from file 1. I am a really beginer in awk programing.
 
this code only produce one file
Really ?
Did you even try it ?
 
Thank @PHV, yes this code able to produce several files, I'm sorry it was mistake, so I can learn more about awk, Thanks again for your kind help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top