Skip to content

Commit

Permalink
Fix more broken/confused one-liners
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshCheek committed Dec 16, 2011
1 parent a4570df commit d9bedb5
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions ruby-one-liners/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ for each of these tasks:

### add leading blanks to right-align all text in 80-column width

ruby -pe '$_ = "%80s\n" % $_.chomp'
ruby -ple '$_="%80s"%$_'
ruby -ple '$_=$_.rjust 80'


### add leading and trailing blanks to center each line in 80 columns
Expand All @@ -83,7 +84,7 @@ for each of these tasks:
### concatenate every 5 lines of input, using , as separator

ruby -e 'ARGF.each_slice(5) { |lines| puts lines.map(&:chomp).join(",") }'

ruby -nle 's=(s||[])<<$_; puts(s.join ",")||s.clear if $.%5==0'

### print first 10 lines of file

Expand All @@ -92,7 +93,7 @@ for each of these tasks:

### print last 10 lines of file

ruby -ne 'puts $_ if $. > 10'
ruby -e 'puts ARGF.readlines[-10..-1]'


### print line 13 of file
Expand Down

0 comments on commit d9bedb5

Please sign in to comment.