![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 11:30 AM |
| 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 09:30 AM |
| Replace \n with \r\n | Chanakya.m | Shell Programming and Scripting | 3 | 07-19-2006 07:20 AM |
| Replace | jda2001 | UNIX for Dummies Questions & Answers | 2 | 09-06-2005 02:20 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
How to replace using SED?
Hi,
I want to change a particular string in a file with another string. This is part of a larger script file. I m using SED for this purpose: sed -e 's/hostname.domainname/${HOST}.${DOMAIN}/g' $sed_file>$tmp_file Where the occurance hostname.domainname has to be replaced with the hostname and domain values. But, I find that the resultant temp file ($tmp_file) contains $HOST and $DOMAIN instead of the values stored in them! I have tried: ${HOST}.${DOMAIN} `${HOST}.${DOMAIN}` "${HOST}.${DOMAIN}" . What ever be the case, the value given between / & / is occuring as is. Is there a way by which I can print the values stored in the variables $HOST and $DOMAIN? Regd, M |
|
||||
|
mahatma,
You could try Code:
HOST=hostname DOMAIN=domainname echo "s/hostname.domainname/$DOMAIN.$HOST/\nwq" | ex Filename For example: Before #>cat filename This is hostname.domainname text file After #>cat filename This is domainname.hostname text file MPH |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|