Skip to content

Instantly share code, notes, and snippets.

@filterfish
Created April 18, 2009 03:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save filterfish/97417 to your computer and use it in GitHub Desktop.
Save filterfish/97417 to your computer and use it in GitHub Desktop.
append_if_no_such_line = lambda do |pattern,file,line|
unless Regexp.new(pattern).match(File.read(file))
File.open(file, "a") { |f| f.puts line }
end
end
append_if_no_such_line.call('^net.ipv4.conf.default.proxy_arp', '/etc/sysctl.conf', 'whatever')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment