using sed delete a line from csv file based on specific data in two separate fields | 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 !!

using sed delete a line from csv file based on specific data in two separate fields

UNIX for Dummies Questions & Answers


Tags
column match, csv file, sed delete line, solved

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 10-10-2012
Chris Eagleson Chris Eagleson is offline
Registered User
 
Join Date: Oct 2012
Last Activity: 17 October 2012, 1:48 PM EDT
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
rdrtx1 rdrtx1 is offline
Registered User
 
Join Date: Sep 2012
Last Activity: 23 September 2014, 12:09 PM EDT
Location: Houston, Texas, USA
Posts: 675
Thanks: 0
Thanked 203 Times in 195 Posts

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

Sponsored Links
    #3  
Old 10-10-2012
Chris Eagleson Chris Eagleson is offline
Registered User
 
Join Date: Oct 2012
Last Activity: 17 October 2012, 1:48 PM EDT
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Perfect. That worked.

Thanks
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 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 12:45 PM.