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!

Omitting certain columns

Status
Not open for further replies.

segment

ISP
Jun 15, 2004
225
US
I have a line sometimes it has 10 columns sometimes it can go to 30 columns... I need everything except fields 3, 4 and 5. Couldn't find an exisiting solution in these archives nor googling... Thanks

perl -e 'print $i=pack(c5,(40*2),sqrt(7600),(unpack(c,Q)-3+1+3+3-7),oct(104),10,oct(101));'
 
cut -d' ' -f 1,2,6-, presuming space is your field separator. Of course there would be an awk solution, but cut is much simpler.

Annihilannic.
 

If whitespace is the field separator, why not simply null out the fields you don't want:

Code:
awk ' { $3=$4=$5=""; print } ' infile
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top