I need to count the number of control A characters in each line of a file and I'm completely stumped because I don't know what the regex for a control A character would be.
counting number occurrences of ^A per line (as a perl one-liner):
perl -ne '{print tr/\cA//, $/}' file
counting total number occurrences of ^A:
perl -ne '{$c += tr/\cA//}END{print $c, $/}' file
(edit: fixed typo)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With