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

Re: grep question



Johann Spies <jspies@sun.ac.za> writes:
> 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'.

Because both 'cron' and 'grep cron' match the pattern 'cron'.
'[c]ron' also matches the word 'cron' (it's an equivalent regular
expression), but it doesn't match 'grep [c]ron'.

-- 
David Maze         dmaze@debian.org      http://people.debian.org/~dmaze/
"Theoretical politics is interesting.  Politicking should be illegal."
	-- Abra Mitchell


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



Reply to: