Skip to content
This repository was archived by the owner on Jun 5, 2024. It is now read-only.
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions ruby_one_liners.md
Original file line number Diff line number Diff line change
Expand Up @@ -470,14 +470,16 @@ $ ruby -ane 'puts $F[1] if $F[0] == "apple"' fruits.txt
42

$ # print first field if second field > 35 (excluding header)
# TODO: Modify comment below to reflect removal of `$.`
$ # same as: perl -lane 'print $F[0] if $F[1]>35 && $.>1' fruits.txt
$ ruby -ane 'puts $F[0] if $F[1].to_i > 35 && $.>1' fruits.txt
$ ruby -ane 'puts $F[0] if $F[1].to_i > 35' fruits.txt
apple
fig

$ # print header and lines with qty < 35
# TODO: Modify comment below to reflect removal of `$.`
$ # same as: perl -ane 'print if $F[1]<35 || $.==1' fruits.txt
$ ruby -ane 'print if $F[1].to_i < 35 || $.==1' fruits.txt
$ ruby -ane 'print if $F[1].to_i < 35' fruits.txt
fruit qty
banana 31
guava 6
Expand Down