bug-coreutils
[Top][All Lists]
Advanced

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

Re: weird bug in tr (translate or delete character)


From: Brian Dessent
Subject: Re: weird bug in tr (translate or delete character)
Date: Mon, 22 Sep 2008 11:57:52 -0700

Arch Drone wrote:

> address@hidden:~/tmp$ ls
> a
> address@hidden:~/tmp$ echo "abcDEF.<>" | tr -d [:alpha:]
> bcDEF.<>
> address@hidden:~/tmp$ mv a b; ls
> b
> address@hidden:~/tmp$ echo "abcDEF.<>" | tr -d [:alpha:]
> .<>

This is not a bug.  Without quoting, [:alpha:] is interpreted by the
shell as a glob that matches the filename 'a', so you're really running
"tr -d a" in the first example.  You need to quote the argument if you
don't want it to spuriously match a filename:

tr -d '[:alpha:]'

You commonly see this also with find, where you have to quote globs that
you want to survive past the shell without interpolation and be passed
on to the command:

find . -name '*.ext'

Brian




reply via email to

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