The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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
remove except ... xyzt UNIX for Dummies Questions & Answers 4 05-15-2008 08:10 AM
How can remove -ksh.log HAA Shell Programming and Scripting 0 07-17-2006 03:59 AM
How to remove ^Z (eof) using sub in awk placroix1 Shell Programming and Scripting 2 05-13-2005 10:40 AM
add/remove rsh UNIX for Dummies Questions & Answers 2 11-18-2002 09:10 PM
smitty, remove user, remove directory as well.. yls177 UNIX for Dummies Questions & Answers 2 11-11-2002 02:43 AM

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

Join Date: Apr 2008
Posts: 4
sed remove

anyone out there knows how to remove pattern <random string> use sed?
  #2 (permalink)  
Old 04-11-2008
aigles's Avatar
aigles aigles is online now Forum Advisor  
Registered User
  
 

Join Date: Apr 2004
Location: Bordeaux, France
Posts: 1,416
Removes string "random string" :
Code:
sed 's/random string//g' inputfile
Removes lines xontaining "random string" :
Code:
sed '/random string/d' inputfile
Jean-Pierre.
  #3 (permalink)  
Old 04-11-2008
jamwong jamwong is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 4
Quote:
Originally Posted by aigles View Post
Removes string "random string" :
Code:
sed 's/random string//g' inputfile
Removes lines xontaining "random string" :
Code:
sed '/random string/d' inputfile
Jean-Pierre.
I have a file with many pattern like <...>
"random string" is just an example
I want to know how to delete every thing in between < and > also "<" and ">".
<first>a<second>b<3rd>
<4th>c
becomes
ab
c

Thanks

Last edited by jamwong; 04-11-2008 at 04:02 PM..
  #4 (permalink)  
Old 04-11-2008
aigles's Avatar
aigles aigles is online now Forum Advisor  
Registered User
  
 

Join Date: Apr 2004
Location: Bordeaux, France
Posts: 1,416
Try :
Code:
sed 's/<\([^>]*\)>/\1 /g' inputfile
Jean-Pierre.
  #5 (permalink)  
Old 04-11-2008
jamwong jamwong is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 4
Quote:
Originally Posted by aigles View Post
Try :
Code:
sed 's/<\([^>]*\)>/\1 /g' inputfile
Jean-Pierre.
Hi aigles,

Thanks for the code.
Sorry, I made a mistake in my example.
The code deletes < and > but it does not delete the content within <>. I'm having trouble to figure out how to remove <, > and the stuff with in.
  #6 (permalink)  
Old 04-11-2008
aigles's Avatar
aigles aigles is online now Forum Advisor  
Registered User
  
 

Join Date: Apr 2004
Location: Bordeaux, France
Posts: 1,416
Code:
sed 's/<[^>]*>//g' inputfile
Jean-Pierre.
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 12:44 PM.


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