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!

Incrementing filenames

Status
Not open for further replies.

jakdelirious

Programmer
Oct 24, 2003
2
US
Hi,

Anyone know how to output each awk 'print' statements into an individual file? Thus a new file should be created each time for each print output. I can't seem to create this file with incrementing filenames. Eg:
footxt.1
footxt.2
footxt.3

cat foo|nawk '{print $0 > "footxt."$FNR}' didn't work for me.

Jak

 
nawk '{print $0 > ("footxt." FNR)}' foo

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
If your input file have a lot of records, you may have to close your output files:
Code:
{out=&quot;footxt.&quot;FNR;print >out;close(out)}

Hope This Help
PH.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top