The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Count of matched pattern occurance palash2k UNIX for Dummies Questions & Answers 3 04-24-2008 04:33 PM
Concatenating multiple lines to one line if match pattern phixsius Shell Programming and Scripting 13 01-24-2008 11:02 PM
Delete a block of text delimited by blank lines when pattern is found gleu Shell Programming and Scripting 17 12-16-2007 11:30 PM
How to delete lines do NOT match a pattern JumboGeng UNIX for Dummies Questions & Answers 1 09-20-2006 06:52 AM
appending with sed based on matched pattern jack1981 Shell Programming and Scripting 2 07-20-2006 07:54 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-22-2006
not4google not4google is offline
Registered User
  
 

Join Date: Oct 2006
Posts: 15
SED: match pattern & delete matched lines

Hi all,

I have the following data in a file x.csv:

> ,this is some text here
> ,,,,,,,,,,,,,,,,2006/11/16,0.23
> ,,,,,,,,,,,,,,,,2006/12/16,0.88
< ,,,,,,,,,,,,,,,,this shouldnt be deleted

I need to use SED to match anything with a > in the line and delete that line, can someone help me out?

Last edited by not4google; 11-22-2006 at 07:17 AM.. Reason: Ammended Title
  #2 (permalink)  
Old 11-22-2006
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,131

Code:
sed '/>/d' x.csv

  #3 (permalink)  
Old 11-22-2006
srikanthus2002's Avatar
srikanthus2002 srikanthus2002 is offline
Registered User
  
 

Join Date: Sep 2006
Location: Can u guess...!
Posts: 160
alternatively you can use the following command


Code:
grep -v ">" x.csv

  #4 (permalink)  
Old 11-22-2006
not4google not4google is offline
Registered User
  
 

Join Date: Oct 2006
Posts: 15
Thanks for the responses - is it possible to have multiple sed commands in a statement so I can for example delete the lines with ">" and then delete instances of lines with "---" in them?

I tried but it doesnt like this:


Code:
sed -e  '/>/d' '/---/d' x

Thanks again,
  #5 (permalink)  
Old 11-22-2006
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,131

Code:
sed -e  '/>/d;/---/d' x

  #6 (permalink)  
Old 11-22-2006
not4google not4google is offline
Registered User
  
 

Join Date: Oct 2006
Posts: 15
Thanks for the quick responses,

I want to search for a particular string and then append to the first line, is this possible with something like the following:


Code:
 sed -e /test/s/$/ testString/; x.csv

This appends testString to the EOL (where test is matched) but I need to append testString to the line above the one matched, is this possible?
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 08:45 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0