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
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?
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:
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'
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
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 03:57 PM.|