Re: annoyances with tr
Philip Rowlands <[email protected]> Tue, 18 Jul 2006 22:17:37 +0100 (BST)
| Newsgroups | gmane.comp.gnu.core-utils.bugs,gmane.comp.gnu.textutils.bugs |
|---|---|
| Message-ID | <[email protected]> |
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