delete some columns | Unix Linux Forums | UNIX for Dummies Questions & Answers

  Go Back    


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

delete some columns

UNIX for Dummies Questions & Answers


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 05-15-2007
su_in99 su_in99 is offline
Registered User
 
Join Date: Mar 2007
Last Activity: 18 November 2009, 6:10 PM EST
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
delete some columns

I've got a data file like the following format.

196004010000 196004020000 8192 24 ueaag 98.793 18.750 20 ---- - 36 23 9999 314.161773681641
196004020000 196004030000 8192 24 ueaag 98.793 18.750 20 ---- - 36 23 9999 314.71533203125
196004030000 196004040000 8192 24 ueaag 98.793 18.750 20 ---- - 36 23 9999 315.208740234375

I need the first and last column as

196004010000 314.161773681641
196004020000 314.71533203125
196004030000 315.208740234375

Would you have any idea to do this job? I'd be grateful with any help.

Many thanks,
su_in99
Sponsored Links
    #2  
Old 05-15-2007
Shell_Life's Avatar
Shell_Life Shell_Life is offline
Registered User
 
Join Date: Mar 2007
Last Activity: 21 June 2012, 3:19 PM EDT
Location: Bahia, Brazil
Posts: 1,203
Thanks: 1
Thanked 103 Times in 100 Posts
su,
See if this would work for you:

Code:
cut -d' ' -f1,14 input_file

Sponsored Links
    #3  
Old 05-15-2007
su_in99 su_in99 is offline
Registered User
 
Join Date: Mar 2007
Last Activity: 18 November 2009, 6:10 PM EST
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Thank you for your quick reply.

But If I would like to save the new file, could you please tell me?

Many thanks indeed

su_in99
    #4  
Old 05-15-2007
Shell_Life's Avatar
Shell_Life Shell_Life is offline
Registered User
 
Join Date: Mar 2007
Last Activity: 21 June 2012, 3:19 PM EDT
Location: Bahia, Brazil
Posts: 1,203
Thanks: 1
Thanked 103 Times in 100 Posts
Here it is:

Code:
cut -d' ' -f1,14 input_file > output_file

Sponsored Links
    #5  
Old 05-15-2007
su_in99 su_in99 is offline
Registered User
 
Join Date: Mar 2007
Last Activity: 18 November 2009, 6:10 PM EST
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
sorry but I've got the wrong column. I need the first and last column.

196004010000 18.750
196004010000 18.750
196004010000 18.750

Many thanks,
S
Sponsored Links
    #6  
Old 05-15-2007
Shell_Life's Avatar
Shell_Life Shell_Life is offline
Registered User
 
Join Date: Mar 2007
Last Activity: 21 June 2012, 3:19 PM EDT
Location: Bahia, Brazil
Posts: 1,203
Thanks: 1
Thanked 103 Times in 100 Posts
su,
The solution I gave to you does work with the sample data you gave here.
You must be not be using exactly the solution I purposed or you are using
a different file layout from what is here.
Sponsored Links
    #7  
Old 05-15-2007
su_in99 su_in99 is offline
Registered User
 
Join Date: Mar 2007
Last Activity: 18 November 2009, 6:10 PM EST
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Thank you very for your code.
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Delete rows with particular number of columns Pratik4891 Shell Programming and Scripting 2 11-01-2011 05:37 AM
How to delete all columns that start with a specific value evelibertine UNIX for Dummies Questions & Answers 3 06-01-2011 03:29 AM
delete lines and columns from a file jdhahbi UNIX for Dummies Questions & Answers 4 08-26-2010 10:35 PM
How to delete last 3 columns in a file reva UNIX for Dummies Questions & Answers 3 07-10-2009 01:41 AM
Using 'sed' to delete or ignore columns in a dataset aarif UNIX for Dummies Questions & Answers 4 07-21-2008 12:22 PM



All times are GMT -4. The time now is 01:56 AM.