tag 74103 notabug
close 74103
stop
On 30/10/2024 09:42, Jakub Filipiuk wrote:
Hi
I stumble upon situation, when characters order in tr affects it result.
For example:
$ echo "some: 123 fa-ncy string, " | tr -d ',-:'
some fancy string
When colon is moved before hyphen, result is correct
$ echo "some: 123 fa-ncy string, " | tr -d ',:-'
some 123 fancy string
This is working as expected as the hyphen denotes a range of characters.
Placing a hyphen at the end is the most portable way to avoid this.
As a GNU extension, you can also backslash escape the hyphen like \-
cheers,
Pádraig