bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: annoyances with tr


From: Philip Rowlands
Subject: Re: annoyances with tr
Date: Tue, 18 Jul 2006 22:17:37 +0100 (BST)

On Tue, 18 Jul 2006, icewind wrote:

input: "abc123abc"
call: tr "abc123abc" -d '[^0-9]'
output:abcabc

regex-rule: "^" is for "negating" the match

output should be "123"

(Please note - the bug-textutils address you mailed suggests that you have a rather old version of tr. textutils, fileutils, and sh-utils merged a while back into coreutils. Please consider upgrading.)

Firstly, I can't reproduce the example given:
$ tr "abc123abc" -d '[^0-9]'
tr: extra operand `[^0-9]'

The data to be manipulated is not passed to tr on the commandline.

Also, the arguments to tr are not regexs, they're character sets. The desired output could be obtained with:

$ echo acb123abc | tr -d -c '0-9'
123

The square brackets are unnecessary in this context, and tr treats them as extra characters to be preserved.


Cheers,
Phil




reply via email to

[Prev in Thread] Current Thread [Next in Thread]