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 a occurrence soemac Shell Programming and Scripting 5 12-15-2008 06:10 AM
How to print lines till till a pattern is matched in loop anoopvraj Shell Programming and Scripting 3 10-30-2008 10:36 PM
Using sed to substitute first occurrence quixoticking11 Shell Programming and Scripting 2 07-09-2008 11:36 AM
Replace second occurrence only lyoncc Shell Programming and Scripting 5 12-26-2007 11:21 PM
awk + last occurrence agibbs UNIX for Dummies Questions & Answers 2 10-06-2007 04:32 PM

 
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
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 06-03-2009
benitdhotekar benitdhotekar is offline
Registered User
  
 

Join Date: May 2008
Posts: 9
Smile capture till first occurrence.

Hi,

In my file I have following to lines
-------------------------------------------
C:/India/Apple/Mumbai/Red_Apple/Apple.txt

cd C:/India/Apple && run
-------------------------------------------


I want to replace "C:/India/Apple" with "D:/Test/Red_Apple" whereever the pattern "C:/India/Apple" occurs in my file.

what I want is to capture the first occurrence of "Apple" after "C:" in the line.

Please help me out.

I am trying
s/C:\/.*?Apple/D:\/Test\/Red_Apple/g

but it is replacing "C:/India/Apple/Mumbai/Red_Apple/Apple.txt" to "D:/Test/Red_Apple.txt"

Note: C:/India/Apple can be anything. Meaning it can be C:/India/Mango/Apple etc etc.

Last edited by benitdhotekar; 06-03-2009 at 03:34 AM.. Reason: Updated
 

Bookmarks

Tags
regex

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 09:59 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