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!

to print columns n to NF with newline after each line

Status
Not open for further replies.

niruj

Technical User
Dec 21, 2005
1
NL

How do I print columns n to NF of a file, where NF varies for each line, such that the output preserves the spacings between the columns and includes the newline (something like the op of cut) ?

Thanks
Mohan.
 
Try...
Code:
awk -v n=4 -F '[ \t]+' '{s="^";for(i=1;i<n;i++)s=s $i FS;sub(s,"")};1' file1
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top