Reputation: 149
I am having a issue where i am trying to substitute a variable in sed command while executing it in TCL shell. Below is what i tried.
set variable 5
exec sed "s/test1\$/test1;test1 $variable/g" file1 > file2
I see below error. Error: sed: -e expression #1, char 75: unknown option to `s' Use error_info for more info. (CMD-013)
I have tried some links on stack overflow but that did not help. Using a Variable in a sed command called in Tcl Script
Upvotes: 0
Views: 307
Reputation: 15482
The general approach is correct. Try this1:
▶ expect
expect1.1> set var /bin/sh
/bin/sh
expect1.2> exec sed -n "s%:$var\$%:/bin/bash%p" /etc/passwd
root:*:0:0:System Administrator:/var/root:/bin/bash
expect1.3> exec sed -n "s%:$var\$%:/bin/bash%p" /etc/passwd > /tmp/log
Analysing your error message:
Error: sed: -e expression #1, char 75: unknown option to `s'
Note that sed received at least 75 characters- far more than in your code example. Does that help you to figure out what went wrong? If not, update with the actual code you tried.
1 Noting that expect just adds some extensions onto TCL, and I don't have TCL on my laptop.
Upvotes: 2