Re: [R] OT UNIX grep question

2006-08-10 Thread francoisromain
Hi,

You have to learn about regular expressions. Then you'll come up with something
like :

grep ^dog$ /usr/share/dict/words

Cheers,

Romain


Selon Erin Hodgess [EMAIL PROTECTED]:

 Dear R People:

 I want to use the grep command in UNIX/Linux to check
 some words from the dictionary.

 Let's say I use:

 grep dog /usr/share/dict/words

 and I get back

 bulldog
 dog
 dogged

 and so on.

 How could I just get back dog with the grep command please?

 Thanks,
 Sincerely
 Erin Hodgess
 Associate Professor
 Department of Computer and Mathematical Sciences
 University of Houston - Downtown
 mailto: [EMAIL PROTECTED]

 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] OT UNIX grep question

2006-08-10 Thread Rolf Turner
[EMAIL PROTECTED] wrote:

 You have to learn about regular expressions. Then you'll come up with
 something like :
 
 grep ^dog$ /usr/share/dict/words

*You* have to learn about shell syntax.  The foregoing doesn't
work; it gives an ``Illegal variable name.'' error.  To protect
against the shell interpretation of the dollar sign you have
to use *single* quotes.

grep '^dog$' /usr/share/dict/words

*does* work.  (Try it!)

cheers,

Rolf Turner
[EMAIL PROTECTED]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] OT UNIX grep question

2006-08-10 Thread Chris wallace
On 10/08/06, Rolf Turner [EMAIL PROTECTED] wrote:

 [EMAIL PROTECTED] wrote:

 grep '^dog$' /usr/share/dict/words


or (simpler, in my view)

   grep -w dog /usr/share/dict/words

Chris.

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] OT UNIX grep question

2006-08-10 Thread Jan T. Kim
On Thu, Aug 10, 2006 at 08:51:36AM -0300, Rolf Turner wrote:
 [EMAIL PROTECTED] wrote:
 
  You have to learn about regular expressions. Then you'll come up with
  something like :
  
  grep ^dog$ /usr/share/dict/words
 
 *You* have to learn about shell syntax.  The foregoing doesn't
 work; it gives an ``Illegal variable name.'' error.  To protect
 against the shell interpretation of the dollar sign you have
 to use *single* quotes.
 
   grep '^dog$' /usr/share/dict/words
 
 *does* work.  (Try it!)

you're perfectly right about single quotes being the correct thing to use
here, but not all shells are insisting on linguistic correctness the way
[t]csh does. bash leaves constructs that it cannot expand as they are, so
the variant with double quotes does work as expected with bash (although
through a mechanism that might be unexpected by most).

Best regards, Jan
-- 
 +- Jan T. Kim ---+
 | email: [EMAIL PROTECTED]   |
 | WWW:   http://www.cmp.uea.ac.uk/people/jtk |
 *-=  hierarchical systems are for files, not for humans  =-*

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] OT UNIX grep question

2006-08-10 Thread francoisromain
Selon Rolf Turner [EMAIL PROTECTED]:

 [EMAIL PROTECTED] wrote:

  You have to learn about regular expressions. Then you'll come up with
  something like :
 
  grep ^dog$ /usr/share/dict/words

 *You* have to learn about shell syntax.  The foregoing doesn't
 work; it gives an ``Illegal variable name.'' error.  To protect
 against the shell interpretation of the dollar sign you have
 to use *single* quotes.

   grep '^dog$' /usr/share/dict/words

 *does* work.  (Try it!)


Hi,

Sorry for inconvenience, both are working on my fedora gnu/linux bash, Jan gave
the explanation (Thanks!).

BTW, did you really think I didn't try the double quote call ?
But do not hesitate if **you** see something **I** should learn.

Cheers,

Romain

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] OT UNIX grep question

2006-08-10 Thread francoisromain
Selon Chris wallace [EMAIL PROTECTED]:

 On 10/08/06, Rolf Turner [EMAIL PROTECTED] wrote:
 
  [EMAIL PROTECTED] wrote:
 
  grep '^dog$' /usr/share/dict/words
 
 
 or (simpler, in my view)

grep -w dog /usr/share/dict/words

 Chris.



Well, for the record it's does not work with my settings.
Maybe *Mr Turner* can give you a lesson as well. Sorry I'm just in the mood for
a joke ...

Romain

$ grep -w dog /usr/share/dict/words
bird-dog
bull-dog
cat-and-dog
dog
dog-banner

water-dog
wolf-dog
yellow-dog

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] OT UNIX grep question

2006-08-10 Thread Chris wallace
On 10/08/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:

 Selon Chris wallace [EMAIL PROTECTED]:

 grep -w dog /usr/share/dict/words

 Well, for the record it's does not work with my settings.
 Maybe *Mr Turner* can give you a lesson as well. Sorry I'm just in the
 mood for
 a joke ...

 Romain

 $ grep -w dog /usr/share/dict/words
 bird-dog
 bull-dog
 cat-and-dog
 dog
 dog-banner


Ah - the original example didn't include hyphenated words (and nor does my
/usr/share/dict/words).  To match whole lines try grep -x.  Does that do it?

C.

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] OT UNIX grep question

2006-08-09 Thread Erin Hodgess
Dear R People:

I want to use the grep command in UNIX/Linux to check
some words from the dictionary.

Let's say I use:

grep dog /usr/share/dict/words

and I get back

bulldog
dog
dogged

and so on.

How could I just get back dog with the grep command please?

Thanks,
Sincerely
Erin Hodgess
Associate Professor
Department of Computer and Mathematical Sciences
University of Houston - Downtown
mailto: [EMAIL PROTECTED]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.