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!

Creating many O/P files from one I/P 1

Status
Not open for further replies.

jennyj

MIS
Sep 3, 2001
5
GB
I am fairly new to awk/nawk and our expert is away on holiday, so I hope someone can help.

I have an input file eg

001,ABC,99900003,500042949,CHRIS
001,CDE,99900011,500042999,DAVID
002,ABC,99900099,500099999,JAMES
003,ZZZ,99900088,500088888,PAUL

I need to create a separate output file dependant on the first 3 characters
eg all 001 lines to be written to file "output.001"
all 002 lines to be written to file "output.002"
etc

Hope you can help
Thanks
jennyj
 
Perhaps just...

awk -F, '{print > "output." $1}' infile
 
Brilliant, that works fine.
I had been trying to work out a loop routine instead of keeping it simple.
Many thanks
jennyj
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top