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

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

Nuget pack csproj using nuspec -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -