Skip to content

Commit

Permalink
Merge pull request #1 from KL-7/master
Browse files Browse the repository at this point in the history
Alternative line numbering and comment fix.
  • Loading branch information
JoshCheek committed Jan 12, 2012
2 parents d9bedb5 + 27c29a0 commit d51fd94
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion ruby-one-liners/Readme.md
Expand Up @@ -17,6 +17,11 @@ for each of these tasks:
# (also, 1.9 only)
ruby -e 'l=-> line {puts "#$. #{line}"}; ARGV.each { |name| File.foreach name, &l}; $stdin.each &l'

# alternative version
# $<.pos, that is ARGF#pos, returns position (in bytes) in the current file
# that allows us to reset $. at the end of the first line of each file
ruby -ne '$. = 1 if $<.pos - $_.size == 0; puts "#$. #$_"'


### add line numbers for all files together

Expand Down Expand Up @@ -106,7 +111,7 @@ for each of these tasks:
ruby -ne 'puts $_ unless $_ == "\n"'


### delete consecutive duplicate lines from file
### delete consecutive empty lines (all but one in each group) from file

ruby -ne 'puts $_ if /^[^\n]/../^$/'

Expand Down

0 comments on commit d51fd94

Please sign in to comment.