Re: locales problem / grep question
On Wed 19 Mar 2003 13:04:59 +0000(-0500), Matt Price wrote:
[...]
> if I run emacs -nw, the error doesn't occur, so I asusme the issue is
> x-specific. Anyway, though people were sympathetic, no one seemed to
> have seen this specific problem before (if it's familiar, help would
> still be absolutely welcome!)... it's been bugging me on and off, and
Sorry, I can't help there.
> today I tried to use grep to look for this string somewhere in some
> file on the system.
>
> now obviously the following doesn't work:
> grep -r -*-*-medium-r-normal--14-*-*-*-c-*-iso8859-15 /
> (*'s need to be escaped)
>
> slightly less obviously, neither does this:
> grep -r -\*-\*-medium-r-normal--14-\*-\*-\*-c-\*-iso8859 /
> (grep looks for a switch after the '-')
>
> and neither did this, which I tried more or less at random:
> grep -r \-\*-\*-medium-r-normal--14-\*-\*-\*-c-\*-iso8859 /
>
> now, I've worked around the problem by using this:
> grep -r medium-r-normal.*iso8559 /
>
> (which is running right now, and will probably take a while!) but I'm
> curious: what's the CORRECT way to search for a string like this,
> since I'm not interested in the dozens of files that seem to contain
> similar (but not identical) expressions?
I'm not sure whether there's a definitive method, but see what you think of this:
1. Use -e before a pattern beginning with a -, so that grep won't interpret the pattern as an option.
2. Quote the pattern string to prevent the shell interpreting special characters (* in your example).
3. Escape regular expression characters to force grep to match them exactly (* again in your example).
So your grep would look like
grep -r -e '-\*-\*-medium-r-normal--14-\*-\*-\*-c-\*-iso8859-15' /
By the way, recursively searching from / will search all files on any network file systems you have mounted, which can take ages. If this affects you, you could try something like
find / -xdev -type f | xargs -r grep -H -e '-\*-\*-medium-r-normal--14-\*-\*-\*-c-\*-iso8859-15'
or
find / ! -fstype nfs -type f | (etc.)
--
Cheers,
Clive
Reply to: