Skip to content

Instantly share code, notes, and snippets.

@DevGW
Last active April 5, 2023 14:44
Show Gist options
  • Save DevGW/090ff27af03d70665abdc2f78dca17dd to your computer and use it in GitHub Desktop.
Save DevGW/090ff27af03d70665abdc2f78dca17dd to your computer and use it in GitHub Desktop.
shell :: fixsite.rb #bash #rails
#!/usr/bin/env ruby
file_names = ['config/database.yml']
text = File.read(file_names[0])
new_contents = text.gsub(/\/tmp\/mysql\.sock/, "\/var\/lib\/mysql\/mysql\.sock")
# To merely print the contents of the file, use:
# puts new_contents
# To write changes to the file, use:
File.open(file_names[0], "w") {|file| file.puts new_contents }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment