Skip to content

Instantly share code, notes, and snippets.

@leemour
Last active December 16, 2015 11:19
Show Gist options
  • Save leemour/5426806 to your computer and use it in GitHub Desktop.
Save leemour/5426806 to your computer and use it in GitHub Desktop.
Regex to replace end in config files through bash
class Test
def procedure
nil
end
end
I am trying to achieve this:
class Test
def procedure
nil
finish
finish
sed -i '/end$/{N; s/end\nend/finish\nfinish/}' test.rb
sed -i '/end$/N;/\nend/s/end/finish/g' test.rb
sed -i '/end$/N;//s/end/finish/g' test.rb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment