Reputation: 397
# test-1, this is okay, which deletes the given line in given 'cshrc' file
sed -i '\:alias reml rm -rf ${ENIP_HOME}/log/*:d' cshrc
# test-2, This does not delete the line in given 'cshrc' file
LINE="alias reml rm -rf ${ENIP_HOME}/log/*"
sed -i '\:$LINE:d' cshrc
Above sed cmd does not remove the line from 'cshrc; file, How i can perform line deletion in test-2 ?
Upvotes: 0
Views: 36
Reputation: 5843
There's a difference between single quotes ('
) and double quotes ("
) when it comes to variable expansion. In your setting it suffices to just replace the double quotes by single quotes in the LINE=
definition, so that ${ENIP_HOME}
is carried over without being replaced (by the empty string, if the variable is not defined).
You also need to use double quotes in the sed
line, so that $LINE
is replaced by the definition of the variable.
Upvotes: 1