shell help: check for regex in variable

Ian Petersen ispeters-Re5JQEeQqe8AvxtiuMwx3w at public.gmane.org
Mon Mar 12 19:45:58 UTC 2007


On 3/12/07, Sergey Semenyuk <ssemenyuk-5xk6gukWl5lWk0Htik3J/w at public.gmane.org> wrote:
> if  [ -z "`echo $pidfile | egrep -e '\.pid$'`" ]; then
>   doesn't have pid at the end

You could probably also do that this way:

if echo $pidfile | grep -q '\.pid$'; then
 echo it does have pid at the end;
fi

Ian

-- 
Tired of pop-ups, security holes, and spyware?
Try Firefox: http://www.getfirefox.com
--
The Toronto Linux Users Group.      Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists





More information about the Legacy mailing list