SUBJECT: How to grep for a "`g'"? (gives an "Unmatched `" err)
You know how many documents do, uh, "2nd-level:" quoting around
words or phrases by using *single* quotes, but not like this:"
'a single-quoted phrase'
but like this:
'a single-quoted phrase`
using a back-quote to close it off.
So, I want to find (grep) all occurrences of
'g`
in a file.
Here's what I've tried so far -- with no success:
| 317 ====> egrep -n "`g'" `cat userdocs.nam` > ! t5.loc
| Unmatched `.
| 318 ====> egrep -n "\`g\'" `cat userdocs.nam` > ! t5.loc
| Unmatched `.
| 319 ====> egrep -n '[']g[`]' `cat userdocs.nam` > ! t5.loc
| Unmatched `.
| 320 ====> egrep -n "[']g[`]" `cat userdocs.nam` > ! t5.loc
| Unmatched `.
Oh, I'm using tcsh.
So, here's with sh (Bourne):
468 ====> sh
$
$ egrep -n "`g'" `cat userdocs.nam`
g": not found
usr_01.txt:1:*usr_01.txt* For Vim version 6.3. Last change: 2004 May 01
usr_01.txt:2:
usr_01.txt:3: VIM USER MANUAL - by Bram Moolenaar
usr_01.txt:4:
usr_01.txt:5: About the manuals
usr_01.txt:6:
usr_01.txt:7:
usr_01.txt:8:This chapter introduces the manuals available with Vim. Read this to know the
usr_01.txt:9:conditions under which the commands are explained.
$
$ egrep -n "\`g\'" `cat userdocs.nam` | head
$
$ egrep -n '[']g[`]' `cat userdocs.nam` | head
>
>
$ echo HUH?
HUH?
$
$
$ egrep -n "[']g[`]" `cat userdocs.nam` | head
]: not found
egrep: Unmatched [ or [^
$
$
$
Any ideas?
(please do first try your solutions, if any:
this quoting-stuff is a real bear!)
Thanks,
David
|
|
0
|
|
|
|
Reply
|
dkcombs
|
9/6/2007 12:15:48 AM |
|
On 5 Sep 2007 20:15:48 -0400 dkcombs@panix.com (David Combs) wrote:
> SUBJECT: How to grep for a "`g'"? (gives an "Unmatched `" err)
>
>
> You know how many documents do, uh, "2nd-level:" quoting around
> words or phrases by using *single* quotes, but not like this:"
>
> 'a single-quoted phrase'
>
> but like this:
>
> 'a single-quoted phrase`
>
> using a back-quote to close it off.
they don't do that. they `do this', or ``this'', to distinguish between
opening and closing quotes.
anyway, using double quotes interprets your args so you simply have to
escape the backquote: "\`g'".
Or use single quotes but then you have to escape the quote you are
trying to match: '`g\''.
-frank
|
|
0
|
|
|
|
Reply
|
Frank
|
9/6/2007 12:50:26 AM
|
|
On 5 Sep 2007 20:15:48 -0400, dkcombs@panix.com (David Combs) wrote:
> SUBJECT: How to grep for a "`g'"? (gives an "Unmatched `" err)
>
> You know how many documents do, uh, "2nd-level:" quoting around
> words or phrases by using *single* quotes, but not like this:"
>
> 'a single-quoted phrase'
>
> but like this:
>
> 'a single-quoted phrase`
>
> using a back-quote to close it off.
Escape your backquotes; when unescaped, they are interpreted by the
shell as the start of inline commands to be substituted by their output.
For example, look at the output of:
$ date
Thu Sep 6 04:22:19 EEST 2007
$ echo +++ "`date`" +++
+++ Thu Sep 6 04:22:31 EEST 2007 +++
$ echo +++ "\`date'" +++
+++ `date' +++
$
Note the way the actual output of _running_ the date(1) utility is
substituted in the second command.
Note how this substitution doesn't happen in the third command.
HTH,
Giorgos
|
|
0
|
|
|
|
Reply
|
Giorgos
|
9/6/2007 1:23:41 AM
|
|
In article <87fy1sk2n6.fsf@kobe.laptop>,
Giorgos Keramidas <keramida@ceid.upatras.gr> wrote:
>On 5 Sep 2007 20:15:48 -0400, dkcombs@panix.com (David Combs) wrote:
>> SUBJECT: How to grep for a "`g'"? (gives an "Unmatched `" err)
>>
>> You know how many documents do, uh, "2nd-level:" quoting around
>> words or phrases by using *single* quotes, but not like this:"
>>
>> 'a single-quoted phrase'
>>
>> but like this:
>>
>> 'a single-quoted phrase`
>>
>> using a back-quote to close it off.
>
>Escape your backquotes; when unescaped, they are interpreted by the
>shell as the start of inline commands to be substituted by their output.
>
>For example, look at the output of:
>
>$ date
>Thu Sep 6 04:22:19 EEST 2007
>$ echo +++ "`date`" +++
>+++ Thu Sep 6 04:22:31 EEST 2007 +++
>$ echo +++ "\`date'" +++
>+++ `date' +++
>$
>
>Note the way the actual output of _running_ the date(1) utility is
>substituted in the second command.
>
>Note how this substitution doesn't happen in the third command.
>
>HTH,
>Giorgos
>
Thanks to both of you for your answers.
Problem is, I guess I mis-specified the problem:
I believe that you guys were addressing how to *write*
that quoted-q text such that later on an egrep
can find it.
The actual problem is that the text containing the quoted-q
is *someone else's* -- it's *already* writen (actually, it's
an .info-file that I'm searching for that q-thing.
So, the question becomes "how to write a REGEXP that will
find them?
Any clues?
Thanks!
David
PS: I suppose I could try perl, with it's nifty additional
quoting constructs, where you can choose your own string-delimiter.
Although maybe it'd still catch you in the regular-expression
parser?
D.
|
|
0
|
|
|
|
Reply
|
dkcombs
|
9/15/2007 5:58:54 PM
|
|
On Sat, 15 Sep 2007 17:58:54 +0000 (UTC)
dkcombs@panix.com (David Combs) wrote:
> In article <87fy1sk2n6.fsf@kobe.laptop>,
> Giorgos Keramidas <keramida@ceid.upatras.gr> wrote:
> >On 5 Sep 2007 20:15:48 -0400, dkcombs@panix.com (David Combs) wrote:
> >> SUBJECT: How to grep for a "`g'"? (gives an "Unmatched `" err)
> >>
> >> You know how many documents do, uh, "2nd-level:" quoting around
> >> words or phrases by using *single* quotes, but not like this:"
> >>
> >> 'a single-quoted phrase'
> >>
> >> but like this:
> >>
> >> 'a single-quoted phrase`
> >>
> >> using a back-quote to close it off.
> >
> >Escape your backquotes; when unescaped, they are interpreted by the
> >shell as the start of inline commands to be substituted by their
> >output.
> >
> >For example, look at the output of:
> >
> >$ date
> >Thu Sep 6 04:22:19 EEST 2007
> >$ echo +++ "`date`" +++
> >+++ Thu Sep 6 04:22:31 EEST 2007 +++
> >$ echo +++ "\`date'" +++
> >+++ `date' +++
> >$
> >
> >Note the way the actual output of _running_ the date(1) utility is
> >substituted in the second command.
> >
> >Note how this substitution doesn't happen in the third command.
> >
> >HTH,
> >Giorgos
> >
>
> Thanks to both of you for your answers.
>
> Problem is, I guess I mis-specified the problem:
> I believe that you guys were addressing how to *write*
> that quoted-q text such that later on an egrep
> can find it.
>
> The actual problem is that the text containing the quoted-q
> is *someone else's* -- it's *already* writen (actually, it's
> an .info-file that I'm searching for that q-thing.
>
> So, the question becomes "how to write a REGEXP that will
> find them?
>
> Any clues?
>
> Thanks!
>
> David
>
>
> PS: I suppose I could try perl, with it's nifty additional
> quoting constructs, where you can choose your own string-delimiter.
>
> Although maybe it'd still catch you in the regular-expression
> parser?
>
> D.
>
>
>
/home/malcolml> cat userdocs.nam
a test 'just testing`
testing
naming`
qwerty
xxxx`1
/home/malcolml> egrep -n 'g`' userdocs.nam
1:a test 'just testing`
3:naming`
/home/malcolml>
--
Cheers Malcolm ��� (Linux Counter #276890)
SLED 10.0 SP1 x86_64 Kernel 2.6.16.53-0.8-smp
up 5 days 17:59, 4 users, load average: 0.08, 0.07, 0.03
|
|
0
|
|
|
|
Reply
|
Malcolm
|
9/15/2007 6:39:03 PM
|
|
|
4 Replies
344 Views
(page loaded in 0.096 seconds)
Similiar Articles: grep for a "`g'"? (gives an "Unmatched `" err) - comp.unix.solaris ...SUBJECT: How to grep for a "`g'"? (gives an "Unmatched `" err) You know how many documents do, uh, "2nd-level:" quoting around words or phrases by ... Grep string with spaces - comp.unix.shellgrep for a "`g'"? (gives an "Unmatched `" err) - comp.unix.solaris ..... it's nifty additional quoting constructs, where you can choose your own string ... ld: Mismatched ABI (not an ELF file) - comp.sys.hp.hpuxEven though I am using -I../.. +DD64 , it still gives ... Hi, I want to grep for a particular string in a file ... Mismatched ABI (not an ELF ... ... errors attached to EMC ... Finding common lines between text files - comp.unix.programmer ...grep for a "`g'"? (gives an "Unmatched `" err) - comp.unix.solaris ... Finding common lines between text files - comp.unix.programmer ... grep -f b.txt a.txt If b.txt was ... bash commands with pipes immediately suspended (SIGTTOU). - comp ...Sun gives away the software but hardware and support cost money! The ... 0xFFBEF670) Err#2 ENOENT 25257: stat64("/usr/local/sbin/grep", 0xFFBEF670) Err#2 ... Bareword errors? - comp.lang.perl.misc... lt', '>'=>'gt'); s/([&"<>])/&$ent{$1};/g for grep ... I don't give him/her any code, but rather point at ... Bareword errors? - comp.lang.perl.misc Help With Cisco ... Help needed: read 3-dimensional array from a MAT-file in Fortran ...I will try it again today and give you an update. ... Tursa > I tried the code and got the following errors. ... namelist file in Fortran ... help needed for a grep in a ... HP/UX printing queues - comp.sys.hp.hpuxIf any errors are encountered during the diagnostic test ... to verify that a host entry is present: grep "IP ... LPD gives the HP Jetdirect device the ability to emulate ... Generate a CRUD matrix - comp.databases.oracle.serverOr grep those names to : > find the line numbers in the code and go straight ... on obj to new schema; END LOOP; END LOOP; The captured errors would give you ... svc.startd[7] rpcbind misconfigured - comp.unix.solarisAlso, you could grep '^root' /etc/passwd. % grep ^root /etc/passwd root:x:0 ... have booted is free from viruses, worms, and maybe even configuration errors. It gives ... grep for a "`g'"? (gives an "Unmatched `" err) - comp.unix.solaris ...SUBJECT: How to grep for a "`g'"? (gives an "Unmatched `" err) You know how many documents do, uh, "2nd-level:" quoting around words or phrases by ... Grep string with spaces - comp.unix.shell | Computer Groupgrep for a "`g'"? (gives an "Unmatched `" err) - comp.unix.solaris ..... it's nifty additional quoting constructs, where you can choose your own string ... 7/26/2012 10:15:38 AM
|