Skip to content

Instantly share code, notes, and snippets.

@filterfish
Created April 18, 2009 03:36
Show Gist options
  • 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