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

Shell script question. Get info from File 1 to make file 2? 1

Status
Not open for further replies.

josteino

Technical User
Aug 2, 2006
4
NO
My problem is to make a new file based on information saved in File 1. All this files is dynamic and I like to make a cron job on this script. So the new file would generates automaticly.

File 1 looks like this;
123456, 1, 123, abcdef, test1, test2, test3
222333, 2, 223, dedede, test4, test5, test6

New file I would like to bli like this

Probe, Target, 123456, 1, abcdef, test1, 123, test2, test3
Probe, Target, 222333, 1, dedede, test4, 223, test5, test5

The file is big with about 1000 entries and it's running on Linux RH4.

I hope some god shell scripting og Perl scriping user out there can help me with this problem.

Jostein
 
How about:
[tt]
#!/usr/bin/perl
for(<STDIN>)
{
chomp;
if(split/, +/)
{print "Probe, Target, $_[0], $_[1], $_[3], $_[4], $_[2], $_[5], $_[6]\n"}
}
[/tt]
No doubt somebody will come up with a shorter AWK solution.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top