zamboni128 wrote:
I'm trying to search a xml file...
Where are you doing it in your code?
zamboni128 wrote:
...find a line containing a string...
Again, where is this task?
------
So there are two issues in your
sed(1) line.
The first one is that you want to expand the variable
WIN_IMAGE by its value,
using the dollar sign, within single quotes, whereas expansion occurs within double quotes.
The second is that the variable
WIN_IMAGE contains the "/" character, so
sed(1) will treat it as one of its delimiters.
The solution to this issue is to use another delimiter, like a comma, for example.
Also, I'd use the "
${...}" syntax to make the command more readable, and use lowercase variables because they aren't part of the shell environment.
Code:
sed "/<!--/! s,<general image=.*,${win_image},g" "$tmp_dir"/Sysman.xml > "$tmp_dir"/1.xml
Note that this
sed(1) command won't work if you're in an interactive shell with history expansion enabled.
To disable it, run
set +H. ( «
help set » )