add note on ruby -l switch

Quite a useful switch for one-liners
pull/73/head
Dmitriy Non 5 years ago committed by GitHub
parent ed061663ba
commit 10313bda28
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -13,6 +13,10 @@ ruby -e 'puts "Hello world"'
# end
ruby -ne 'puts $_' file.txt
# Beware that with the -n switch $_ contains newline character in the end.
# With the addition of -l switch each line read has the newline character removed.
ls | ruby -lne 'File.rename($_, $_.upcase)'
# The -p switch acts similarly to -n, in that it loops over each of the lines in the input
# after your code has finished, it always prints the value of $_
# Example: replace e with a

Loading…
Cancel
Save