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!

asking command cut

Status
Not open for further replies.

erche

Technical User
Aug 13, 2003
15
ID

Hello,
I have a problem with cut -d -f$list
the requirements of "cut" command, the list have to be sorted increasing.
but, somehow, i have a list which is have to look like this :

1,2,3,4,5,29,25,11,15,231,227,213,217,433,429,415,419,635,
631,617,621,837,833,819,823,1039,1035,1021,1025,1241,1237,
1223,1227,1443,1439,1425,1429,1645,1641,1627,1631,1847,1843,1829,1833,2049,2045,2031,2035,2251,2247,2233,2237

Anyway, the list has to look like that.
So, I hope that somebody would give me suggestions how to make it work ?

Thanks in advance
 
Here is a not very clever way to do it:

[tt]awk -F, '
BEGIN {
for (i=1; i<ARGC; i++) { fields=ARGV }
delete ARGV
}
{
for (i=1; i<ARGC; i++) { printf(&quot;%s,&quot;,$fields); }
print &quot;&quot;
} ' 1 7 4 13 < inputfile[/tt]

Where you replace 1 7 4 13 with the list of field numbers you want to extract.

I had to copy the ARGV array into the fields array and delete ARGV or else it would try and open files called 1, 7, 4, 13, etc.

I'll see if I can think of something better...


Annihilannic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top