I have a command that outputs some text that I would like to input to the sed’s “replaced text” field. But I’m getting the
sed: -e expression #1, char 24: unterminated `s' command error.
Here is the important snippet:
input=$(./mid 1 10 random.txt)
echo $input
cat $1 |sed "s/times/$input/g" > tester5.txt
And here is the command line output:
$ ./Batchtest tester.txt
some random text some random text some random text some random text
sed: -e expression #1, char 24: unterminated `s' command
As you can see the “./mid 1 10 random.txt” outputs some text that I want to plugin to sed’s “replaced text” field, but it’s not working. I’ve tried adding quotes around $input, but that doesn’t help.
Any help would be much appreciated!
With awk, you can put the output in a variable using the
-voption. Using this method, you don’t have to worry about characters special to sed’s syntax in the output.