Skip to content

Instantly share code, notes, and snippets.

@makevoid
Created April 10, 2011 23:28
Show Gist options
  • Select an option

  • Save makevoid/912840 to your computer and use it in GitHub Desktop.

Select an option

Save makevoid/912840 to your computer and use it in GitHub Desktop.
Deletes a line from a file - unix semicolun notation - file:line
#!/usr/bin/env ruby
# Deletes a line from a file - unix semicolun notation - file:line
# Usage:
#
path, line_number = ARGV[0].split(":")
file = ""
File.open(path).readlines.each_with_index do |line, idx|
file << line unless idx == (line_number.to_i-1)
end.to_s
File.open(path, "w").write(file)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment