The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


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 !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
To cut entire column from a file and apend it to another file as another column sakthifire Shell Programming and Scripting 4 06-25-2008 01:27 AM
How to check Null values in a file column by column if columns are Not NULLs Mandab Shell Programming and Scripting 7 03-15-2008 05:57 AM
Dynamic Drop down boxes garric Shell Programming and Scripting 13 10-18-2007 08:54 AM
Drop records with non-numerics in field X akxeman Shell Programming and Scripting 3 08-14-2007 09:55 PM
Drop Users trfrye UNIX for Dummies Questions & Answers 2 08-31-2005 12:39 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-09-2008
Registered User
 

Join Date: Sep 2007
Posts: 4
Stumble this Post!
Drop a Column from a File

Hi,

I need to drop a column from a file. My .txt file having 20 columns first column as GroupBy column which is not necessery in further processing. So i need to create a new files without this column.

Please help how to do this?

Thanks,
Raamc
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 01-09-2008
Tytalus's Avatar
Registered User
 

Join Date: Jun 2003
Location: Scotland
Posts: 248
Stumble this Post!
awk '{$1=""}1' file

should work
Reply With Quote
  #3 (permalink)  
Old 01-09-2008
Registered User
 

Join Date: Sep 2007
Posts: 4
Stumble this Post!
I tested awk '{$1=""}1' file command.
This is just printing 1 space in first column but not removing the first column.
Below is the test data i tested for

I have a file contain data as
"111","000000 305"
...........etc

I want my o/p to be
"000000 305"

If i use above AWK command the o/p coming as
","000000 305

Thanks
Raamc
Reply With Quote
  #4 (permalink)  
Old 01-09-2008
Tytalus's Avatar
Registered User
 

Join Date: Jun 2003
Location: Scotland
Posts: 248
Stumble this Post!
ok - you need to specify your field seperator:

awk '{FS=",";$1=""}1' file
Reply With Quote
  #5 (permalink)  
Old 01-09-2008
radoulov's Avatar
addict
 

Join Date: Jan 2007
Location: Milan, Italy/Varna, Bulgaria
Posts: 1,516
Stumble this Post!
Code:
cut -d, -f2- data
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 10:30 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0