LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 07-07-2011, 06:32 PM   #1
eddyq
LQ Newbie
 
Registered: Nov 2009
Posts: 20

Rep: Reputation: 0
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?
 
Old 07-07-2011, 07:23 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,986
Blog Entries: 11

Rep: Reputation: 880Reputation: 880Reputation: 880Reputation: 880Reputation: 880Reputation: 880Reputation: 880
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:
Code:
echo '`xcvr_cmn_init' | grep xcvr
`xcvr_cmn_init
The above should explain both of your questions?



Cheers,
Tink
 
Old 07-08-2011, 03:24 PM   #3
eddyq
LQ Newbie
 
Registered: Nov 2009
Posts: 20

Original Poster
Rep: Reputation: 0
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'

Last edited by eddyq; 07-08-2011 at 03:30 PM.
 
Old 07-08-2011, 03:57 PM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,986
Blog Entries: 11

Rep: Reputation: 880Reputation: 880Reputation: 880Reputation: 880Reputation: 880Reputation: 880Reputation: 880
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

Last edited by Tinkster; 07-08-2011 at 04:02 PM.
 
Old 07-08-2011, 04:46 PM   #5
eddyq
LQ Newbie
 
Registered: Nov 2009
Posts: 20

Original Poster
Rep: Reputation: 0
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] special character in string variable and grep ted_chou12 Linux - Newbie 4 04-11-2011 07:59 AM
[SOLVED] Grep until certain character or pattern appears ohijames Programming 7 06-28-2010 08:38 PM
grep '^[^1]' h.txt (what does the " ' " character indicate babu198649 Linux - Newbie 4 12-29-2007 10:32 AM
ndiswrapper shows 'driver present, hardware present' but no wlan0 0x12d3 Linux - Wireless Networking 2 05-11-2007 07:43 PM
ndiswrapper - driver present:harware present but no connection esteeven Linux - Wireless Networking 2 12-26-2004 04:06 PM


All times are GMT -5. The time now is 02:29 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration