Search code examples
unixword-countwc

unix word count tool counting characters across multiple lines


How would I apply the word count tool to a task of this nature:

Д

е

с

я

т

ь

д

н

е

й

I want to know how many characters appear but I want to ignore the white space in between the characters.

How can I specify that in the unix word count utility?


Solution

  • If you use tr you can delete new lines and spaces like this:

    $ tr -d '[\n ]' < file
    Десятьдней
    

    Then, pipe to wc with -m for chars:

    $ tr -d '[\n ]' < file | wc -m
    10