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
Interference channel capacity region for randomized fixed-composition codes iBot UNIX and Linux RSS News 0 02-08-2009 07:10 AM
Interference channel capacity region for randomized fixed-composition codes iBot UNIX and Linux RSS News 0 11-26-2008 07:30 AM
How can i take private region backup in veritas younus_syed SUN Solaris 3 09-05-2008 07:26 AM
Finding volumes with mirrored DRL(Dirty Region Log) prasi_in UNIX for Advanced & Expert Users 2 05-26-2008 08:58 AM
stack region yakari UNIX for Advanced & Expert Users 2 12-29-2006 09:34 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 03-19-2009
islegmar islegmar is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 10
Can sed perform editing operations ONLY in the matched region?

Hi:

Let's suppose I want to replace all the | by > ONLY when | is between []. Usually (and it works) I would do something like

sed -e 's/\(\[[^|]*\)|\([^[]*\]\)/\1>\2/g'

where I have to "save" some portions of the matched region and use them with the \n metacharacter. I was wondering if I could execute something like that

SelectTheFragmentsThat Match(/\[[^]]*\]) and then execute in those pieces s/|/>/g and left the rest of the line unchanged

So, a lot of times I want to perform only editing operations in the region matched, and I want lo left thje rest of the line unchanged. Is that possible?

Thanks a lot

Isi
  #2 (permalink)  
Old 03-19-2009
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,522
show a sample file, and show how the output will look like
  #3 (permalink)  
Old 03-19-2009
islegmar islegmar is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 10
Original text

AAAA [one|1] BBBB | CCCCC [two|2] DDDDD


desired result

AAAA [one>1] BBBB | CCCCC [two>2] DDDDD

only the | between [] are changed. I know how to perform the chage (see my post) but I would like to know if it exists a more "intuitive" way in sed.

Thanks a lot

Isi
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 01:51 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