bug-grep
[Top][All Lists]
Advanced

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

Re: Why does grep [^0-9] become grep u?


From: Matthew Woehlke
Subject: Re: Why does grep [^0-9] become grep u?
Date: Fri, 23 Feb 2007 10:35:27 -0600
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.9) Gecko/20061206 Thunderbird/1.5.0.9 Mnenhy/0.7.4.0

David Liontooth wrote:
In two windows of the same KDE konsole, I get this:

$ echo aa | strace grep [^0-9]
execve("/bin/grep", ["grep", "u"], [/* 31 vars */]) = 0
[snip]

(expanding on Andreas' answer...)
[^0-9] is being interpreted by your shell (probably bash) as a globbing sequence that matches any files whose name is a single character that is not a digit. If there are no matches, the glob is passed unaltered, otherwise it is expanded. You probably meant to write "grep '[^0-9]'" (note the single quotes!) to prevent shell expansion. It is ALWAYS good practice to properly quote arguments.

--
Matthew
Vs lbh pna ernq guvf jvgubhg fbsgjner, lbh ner n FREVBHF areq! -- Nqncgrq sebz Znggurj Jva (ivz-qri znvyvat yvfg)





reply via email to

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