Friday, October 02, 2020

Get the Length of Each Line : Something unix wc Can't Do

Replace each line with the character count :

perl -p -e 's/^(.+)$/sprintf("%d",length($1))/e;'

Prefix each line with character count :

perl -p -e 's/^(.+)$/sprintf("%d:$1",length($1))/e;'

No comments: