Reputation: 2733
when i am doing this
sed 1s/#text_to_be_replaced#/replacement_string/ filename
then the output is as expected but when i put it in a shell file and do this
lineNumber=1
sed $lineNumbers/#text_to_be_replaced#/replacement_string/ filename
then it doesn't work as expected the replacement_string
gets inserted one line above the text_to_be_replaced
. Why is it happening ?
Upvotes: 0
Views: 35
Reputation: 5298
It should be:
sed "${lineNumber}s/text_to_be_replaced/replacement_string/" filename
Upvotes: 4