[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: grep question



The [c], I believe, is a character class containing only the letter c. If
you wanted to match "cron" or "tron" you could use '[ct]ron'.

In this case, the only effect is that the ps output for the grep process
won't match its own pattern, so you don't get the spurious item.

ap

----------------------------------------------------------------------
Andrew J Perrin - andrew_perrin@unc.edu - http://www.unc.edu/~aperrin
 Assistant Professor of Sociology, U of North Carolina, Chapel Hill
      269 Hamilton Hall, CB#3210, Chapel Hill, NC 27599-3210 USA


On Mon, 8 Apr 2002, Johann Spies wrote:

> In the grep's info page I find the following which works as said.  But
> I want to know why.  What does the [c] do in this case?
> 
> ------------------------
>   7. Why do people use strange regular expressions on `ps' output?
> 
>           ps -ef | grep '[c]ron'
> 
>      If the pattern had been written without the square brackets, it
>      would have matched not only the `ps' output line for `cron', but
>      also the `ps' output line for `grep'.
> 
> -------------------------------
> 
> Johann
> -- 
> Johann Spies          Telefoon: 021-808 4036
> Informasietegnologie, Universiteit van Stellenbosch
> 
>      "Do not be anxious about anything, but in everything,  
>       by prayer and supplication, with thanksgiving, present
>       your requests to God. And the peace of God, which  
>       transcends all understanding, will guard your hearts  
>       and your minds in Christ Jesus."   Philippians 4:6,7  
> 
> 
> -- 
> To UNSUBSCRIBE, email to debian-user-request@lists.debian.org 
> with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
> 
> 


-- 
To UNSUBSCRIBE, email to debian-user-request@lists.debian.org 
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org



Reply to: