Is it possible to use wc to count the chars of each line instead of the total amount of chars?
e.g.
echo -e foo\\nbar\\nbazz | grep -i ba
returns:
bar
bazz
So why doesn't echo -e foo\\nbar\\nbazz | grep ba | wc -m
return a list of the lengths of those words? (3 and 4)
Suggestions?
P.S.: why are linefeeds counted with wc -m
? wc -l
counts the newlines, so why should wc -m
count them too?
wc -c
you are looking for.wc -c
counts the bytes whilewc -m
counts the characters, but that won't make a difference in this instance where all characters in that sample are single-byte ones.echo 'Stéphane' | wc -m
=9 butecho 'Stéphane' | wc -c
=10