Service to remove all white space from a string?
In Automator, create a new Service with the following settings:


Service receives selected [text] in [Terminal]


Add a Run AppleScript actions, replacing the default code with the code below:

Example AppleScript code:

on run {input, parameters}

    set selText to item 1 of input as text
    set AppleScript's text item delimiters to {space, tab, linefeed, return}
    set selText to text items of selText
    set AppleScript's text item delimiters to {}
    set selText to selText as string

    display dialog ¬
        "The selection contains " &amp; (count characters of selText) ¬
        &amp; " characters." &amp; linefeed &amp; linefeed &amp; selText ¬
        buttons {"OK"} default button 1

end run


Save the Automator Service as, e.g.: Count Selected Characters

Now in Terminal, select the wanted selection, e.g:



Right-click and select Count Selected Characters from the Services context menu.

Example output of the selection show above:





Note: The example AppleScript code is just that and does not employ any error handling and is meant only to show one of many ways accomplish a task. The onus is always upon the User to add/use appropriate error handling as needed/wanted.