Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Another sed ?

Status
Not open for further replies.

pmcmicha

Technical User
May 25, 2000
353
0
0
I am trying to do the following....

VAR=$(cat file) # file is only one string

sed 's/[${VAR}]/TERM=at386-ie/' file > /tmp/file

The problem is that the string is showing up in there like this: TERM=at386-ieM=at386-ie. Any ideas why?

Thanks in advance.
 
what is the string in the file? Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
 
The corrupted string could look like this: RM=at386-ie

The script is designed to replace the corrupted string "RM=at386-ie" with the correct string: "TERM=at386-ie". But since the corrupted string will not always be the same, I can't always search for this.
 
Replace the single quotes with double quotes around your sed command and remove the left and right brackets around your VAR variable like this:

sed "s/${VAR}/TERM-at386-ie/" file > /tmp/file

that should do it for you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top