I am trying to create a rails template that will add code to files at particular line numbers. For example I need to add a route to the config/routes.rb
I have tried sed, gsed(only cause I am on a mac and they say that sed has problems with insert and append), anyway, I was not able to achieve the result I want.
Any help on this will be greatly appreciated.
I have tried several permutations of this command, but none work, here is an example
run "gsed '3 a/This is it' config/routes.rb"
perhaps even another suggestion
EDIT::::::
ok I took a break and when I came back, after reading up on sed, I realized that I needed to write the stream back to the file, but I was doing this before with,
run "gsed '2 a\
Add this line after 2nd line
' config/routes.rb > config/routes.rb"
but the routes file would be blank, so I tried using a different filename(new.routes.rb),
run "gsed '2 a\
Add this line after 2nd line
' config/routes.rb > config/new.routes.rb"
and this worked, so I know what to do now.