Computing.Net > Forums > Linux > need help with sed/awk

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.

need help with sed/awk

Reply to Message Icon

Name: vagabondsolarisnoob
Date: March 16, 2007 at 19:21:01 Pacific
OS: linux redhat
CPU/Ram: intel 2gb
Product: hp 360
Comment:

Hi, I'm looking for a sed/awk script that would basically search one file for a string that contains the word "linux" and replace the string that it finds with the contents of a text file from somewhere else on the system. Can anyone help?

i.e. sed -i s/mysearchstring/withcontent of the other file

thanks!




Sponsored Link
Ads by Google

Response Number 1
Name: nails
Date: March 17, 2007 at 12:42:31 Pacific
Reply:

This should get you started: Use a variation of sed called gres (where $1 would be linux in your case):

file="myfilename"
pattern=$1
replacement=$2
A="`echo | tr '\012' '\001' `"
sed -e "s$A$pattern$A$replacement$A" $file

This was discussed in this thread:

http://www.computing.net/unix/wwwbo...


0
Reply to Message Icon

Related Posts

See More


pass alias args. w/ multi... driver 4 Broadcom & R...



Post Locked

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


Go to Linux Forum Home


Sponsored links

Ads by Google


Results for: need help with sed/awk

Need Help with Basic Bash Script www.computing.net/answers/linux/need-help-with-basic-bash-script/18382.html

Help! I need help with Wine! www.computing.net/answers/linux/help-i-need-help-with-wine/19564.html

Need help with command line www.computing.net/answers/linux/need-help-with-command-line/24568.html