Created
April 10, 2011 23:28
-
-
Save makevoid/912840 to your computer and use it in GitHub Desktop.
Deletes a line from a file - unix semicolun notation - file:line
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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