sed not able to process ~user/.bash_profile

I have a pretty strange problem with sed, if I do with this:

[root@Camel ~]-> sed -i 's/TLRAGENT_IP=.*/TLRAGENT_IP='"${HOST_IP}"'/' ~user/.bash_profile

it's fine. But if I try the following:

[root@Camel ~]-> CONF_FILE="~user/.bash_profile"
[root@Camel ~]-> sed -i 's/TLRAGENT_IP=.*/TLRAGENT_IP='"${HOST_IP}"'/' ${CONF_FILE}
sed: can't read ~user/.bash_profile: No such file or directory

also tried to quote the variable:

[root@Camel ~]-> sed -i 's/TLRAGENT_IP=.*/TLRAGENT_IP='"${HOST_IP}"'/' "${CONF_FILE}"
sed: can't read ~user/.bash_profile: No such file or directory

couldn't figure out where went wrong, please advise.

Shell's version is 3.2.25(1)-release.

Answers


from man bash /EXPANSION

EXPANSION
 Expansion is performed on the command line after it has been
 split  into  words.  There are seven kinds of expansion per-
 formed:  brace expansion,  tilde  expansion,  parameter  and
 variable  expansion, command substitution, arithmetic expan-
 sion, word splitting, and pathname expansion.

 The order of expansions is: brace  expansion,  tilde  expan-
 sion,  parameter, variable and arithmetic expansion and com-
 mand substitution (done in a  left-to-right  fashion),  word
 splitting, and pathname expansion.

The parameter and variable expansion comes after tilde expansion

To have tilde expansion, this can be done at variable definition

CONF_FILE=~user/.bash_profile

instead of

CONF_FILE="~user/.bash_profile"

Need Your Help

Autofac is not filling action filter property

asp.net-mvc-3 autofac action-filter

I have an action filter in an ASP.NET MVC 3 app that needs some dependencies injected into it. I am using Autofac.Mvc3 as the dependency injector.

Problems with pointing to files on local server versus remote

php

I'm having a really silly issue... basically I'm working on a site on a localhost, and a remote host... I am including files by doing the following:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.