-   Linux - Newbie (
-   -   Using grep with the accent character present (

eddyq 07-07-2011 06:32 PM

Using grep with the accent character present
I am filtering some output from gcc with grep. But if the output contains the accent character (`) I run into a problem. For example:

echo `xcvr_cmn_init' | grep xcvr

causes this:

Then I have to press ctrl/c to get back to a prompt.

(1) Can someone tell me what is going on? I suspect that it is trying to match up the accent with another accent. But my output is from gcc and there is no control over the fact that it uses an accent and a single quote around a name.
(2) Can someone tell me how to do the grep so it does not give the ">" prompt but instead locates "xcvr" in my example?

Tinkster 07-07-2011 07:23 PM

The "accent" is not in the output; it's interpreted by the shell
as the start of a sub-command. What you really want to do for
testing with echo is:

echo '`xcvr_cmn_init' | grep xcvr

The above should explain both of your questions?


eddyq 07-08-2011 03:24 PM

That will work because I can control the output of the echo. But I can't control the output of gcc.

So think of it this way. The command is:

gcc main.c | grep xcvr

Where the output of gcc is:

/this/that/the_other/main.c:512: undefined reference to `xcvr_cmn_init'

Tinkster 07-08-2011 03:57 PM

If gcc outputs that the shell shouldn't interact with it.

One thing to note: most of gcc's output is on stderr,
so you probably want to do
gcc main.c |& grep xcvr

eddyq 07-08-2011 04:46 PM

Ok, I got it working. I think I tried to oversimplify my original post because my real case is very involved. When I tried to use the echo command that probably set me back.

All times are GMT -5. The time now is 05:05 AM.