Add to `_perl/1line`

pull/96/head
terminalforlife 5 years ago
parent 341ff5636f
commit 59ac157226

@ -44,6 +44,7 @@ perl -lpe '$\ = $. % 10 ? "\t" : "\n"'
# Number all lines in a file
perl -pe '$_ = "$. $_"'
perl -ne 'print("$. $_")'
# Number only non-empty lines in a file
perl -pe '$_ = ++$a." $_" if /./'
@ -53,6 +54,8 @@ perl -ne 'print ++$a." $_" if /./'
# Number all lines but print line numbers only non-empty lines
perl -pe '$_ = "$. $_" if /./'
perl -pe '$_ = "$. $_" unless /^$/'
perl -pe '/^$/ or $_ = "$. $_"'
# Number only lines that match a pattern, print others unmodified
perl -pe '$_ = ++$a." $_" if /regex/'
@ -82,6 +85,7 @@ perl -E 'say~~grep/./,<>'
# Print the number of empty lines in a file
perl -lne '$a++ if /^$/; END {print $a+0}'
perl -lne '/^$/ && $L++; END{print($L)}'
perl -le 'print scalar(grep{/^$/}<>)'
perl -le 'print ~~grep{/^$/}<>'
perl -E 'say~~grep{/^$/}<>'
@ -89,6 +93,7 @@ perl -E 'say~~grep{/^$/}<>'
# Print the number of lines in a file that match a pattern (emulate grep -c)
perl -lne '$a++ if /regex/; END {print $a+0}'
perl -nE '$a++ if /regex/; END {say $a+0}'
perl -lne '/^#/ && $L++; END{print($L)}'
#
# CALCULATIONS

Loading…
Cancel
Save