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


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

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 10-10-2012
Registered User
 
Join Date: Oct 2012
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
[Solved] using sed delete a line from csv file based on specific data in two separate fields

Hello,

I have a 12 column csv file. I wish to delete the entire line if column 7 = hello and column 12 = goodbye. I have tried everything that I can find in all of my ref books.

I know this does not work

Code:
/^[^,]*,[^,]*,[^,]*,[^,]*,[^,]*,[^,]*,[^,]"hello",[^,]*,[^,]*,[^,]*,[^,]*,[^,]"goodbye"/d

Any ideas?

Thanks

Moderator's Comments:
Please use code tags next time for your code and data.

Last edited by vbe; 10-10-2012 at 11:45 AM..
Sponsored Links
    #2  
Old 10-10-2012
Registered User
 
Join Date: Sep 2012
Location: Houston, Texas, USA
Posts: 571
Thanks: 0
Thanked 173 Times in 167 Posts

Code:
sed '/^[^,]*,[^,]*,[^,]*,[^,]*,[^,]*,[^,]*,"hello",[^,]*,[^,]*,[^,]*,[^,]*,"goodbye"/d' infile

Sponsored Links
    #3  
Old 10-10-2012
Registered User
 
Join Date: Oct 2012
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Perfect. That worked.

Thanks
Sponsored Links
Closed Thread

Tags
column match, csv file, sed delete line

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 line based on count of specific character tiggyboo Shell Programming and Scripting 5 06-25-2012 11:18 AM
[Solved] making each word of a line to a separate line rbalaj16 Shell Programming and Scripting 8 03-26-2012 05:09 AM
Extracting specific lines of data from a file and related lines of data based on a grep value range? Wynner Shell Programming and Scripting 3 05-18-2011 11:35 AM
Match data based on two fields, and append to a line jamessmith01 Shell Programming and Scripting 20 09-06-2010 12:22 PM
Delete line in file based on data in another file earth_goddess Shell Programming and Scripting 1 12-29-2008 09:47 AM



All times are GMT -4. The time now is 05:15 AM.