linux - Strange Behaviour of [SED] when put in shell script -
when doing
sed 1s/#text_to_be_replaced#/replacement_string/ filename
then output expected when put in shell file ,
linenumber=1 sed $linenumbers/#text_to_be_replaced#/replacement_string/ filename
then doesn't work expected replacement_string
gets inserted 1 line above text_to_be_replaced
. why happening ?
it should be:
sed "${linenumber}s/text_to_be_replaced/replacement_string/" filename
Comments
Post a Comment