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

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Replacing a pattern with a variable

Reply to Message Icon

Name: prekida
Date: July 26, 2005 at 14:16:54 Pacific
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



Sponsored Link
Ads by Google

Response Number 1
Name: Jim Boothe
Date: July 26, 2005 at 15:48:21 Pacific
Reply:

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


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Replacing a pattern with a variable

How to replace a string w/ var www.computing.net/answers/unix/how-to-replace-a-string-w-var/7439.html

replacing a character with a tab www.computing.net/answers/unix/replacing-a-character-with-a-tab/4966.html

replace pattern with new line www.computing.net/answers/unix/replace-pattern-with-new-line/7944.html