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
replace charandevu Shell Programming and Scripting 6 04-07-2008 12:30 PM
replace last / by | naikaa Shell Programming and Scripting 6 01-17-2008 02:19 AM
How to replace into Vi ravi.sadani19 Shell Programming and Scripting 5 06-25-2007 10:30 AM
Replace \n with \r\n Chanakya.m Shell Programming and Scripting 3 07-19-2006 08:20 AM
Replace jda2001 UNIX for Dummies Questions & Answers 2 09-06-2005 03:20 PM

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 05-16-2008
javeed7 javeed7 is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 34
Replace Help

Hi,
djfksdjk)))) kmmm jfdfjk))))
I want to replace the first ')' after kmmm with #.
The output would be djfksdjk)))) exists jfdfjk#)))

Can anyone help on this?
  #2 (permalink)  
Old 05-16-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
Code:
sed 's/\(kmmm[^)]*\))/\1#/' filename
There are different variants of sed; try different backslash patterns if yours doesn't like \(...\)
  #3 (permalink)  
Old 05-16-2008
Franklin52 Franklin52 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,313
If the format of the lines are the same, in the light of the positions of the ")" signs:

Code:
sed 's/\(.*[a-z]\))\(.*\)/\1#\2/' file
Regards
  #4 (permalink)  
Old 05-16-2008
shamrock shamrock is offline Forum Advisor  
Registered User
  
 

Join Date: Oct 2007
Location: USA
Posts: 750
Code:
echo "djfksdjk)))) kmmm jfdfjk))))" | sed 's/\([a-z]\))/\1#/2'
djfksdjk)))) kmmm jfdfjk#)))
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 07:29 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