Computing.Net > Forums > Unix > Replacing a pattern with a variable

Replacing a pattern with a variable

Reply to Message Icon

Original Message
Name: prekida
Date: July 26, 2005 at 14:16:54 Pacific
Subject: Replacing a pattern with a variable
OS: Solaris
CPU/Ram: 8/16G
Comment:

I need to replace anything immediately after the pattern "standard01/" in a file with the value of a variable
I don't know the length of the characters stored in that variable. - that might vary.
I know there is some string after the pattern "standard01/", i don't know the what the string is or the length of it. but i know after that string following "standard01/", there is blank space and after that a word called "buf" in that file

So, the string following the pattern "standard01/" for example looks like
"special_previlege_datetime.lst" followed by a space and then a string begins with "buf" - when in the process of replacing the value of the variable right after the above pattern "standard01/" - i should not start overwriting the next string "buf"
- in other words i should try to replace/write the value of the variable starting
immediately after "standard01/" and before the next word "buf" begins.

Please provide your advice.
Your help is greatly apprecitaed.
Thanks


Report Offensive Message For Removal


Response Number 1
Name: Jim Boothe
Date: July 26, 2005 at 15:48:21 Pacific
Subject: Replacing a pattern with a variable
Reply: (edit)

sed "s/standard01\/.* buf/standard01\/$var buf/"


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Replacing a pattern with a variable

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software