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

create several files

Status
Not open for further replies.

kubabuk

Technical User
Joined
Jan 31, 2007
Messages
4
Location
GB
Hi there,

I was just wondering what I am doing wrong? I wanted to save output in multiply files. but only test2.txt has a content.

awk 'BEGIN {vara = "test"; for (i =1; i <= 20; i++) print vara i }' > c:/test.txt > c:/test2.txt

Btw. Is it possible to have loops in loops in awk?

Thanks for help

kuba
 
I wanted to save output in multiply files
man tee
Is it possible to have loops in loops in awk
yes

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hi

[tt]awk[/tt] can write to files itself.
Code:
awk 'BEGIN {vara = "test"; for (i =1; i <= 20; i++) { print vara i > "test"i".txt"; close("test"i".txt") }}'

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top