Lobo Lobo - 1 year ago 128
Linux Question

Error TR command width :punct: param

I have the following command:

cat original.txt | tr [:upper:] [:lower:] | tr -d [:digit:] |
tr -d [:punct:] > preproces.txt

And the system returns me the following error.

when translating, the only character classes that may appear in
replaceString are 'upper' and 'lower'

The problem is giving:

tr -d [:punct:]

What's the solution to this problem?

I have searched Google and StackOverflow and don't find an answer to this problem.

Tiny edit (but significant for cut&pasters):
Changed '--d' to '-d' before [:punct:]
the '--d' was being rendered as '\342\200\223d'
and the rendered difference was nearly invisible to the eye.

Answer Source

Try the following command :

tr '[:upper:]' '[:lower:]' < original.txt  |
    tr -d '[:digit:]' |
    tr –d '[:punct:]' > preproces.txt

This avoid the infamous useless use of cat :


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download