shell help: check for regex in variable
Chris F.A. Johnson
cfaj-uVmiyxGBW52XDw4h08c5KA at public.gmane.org
Mon Mar 12 17:07:25 UTC 2007
On Mon, 12 Mar 2007, Neil Watson wrote:
> How can I check that a variable ends in .pid?
>
> loose example
> pidfile="/var/run/myproc.pid"
>
> if [[ $pidfile contains ".*\.pid$" ]]
>
> Is this possible?
case $pidfile in
*.pid)
true
;;
*)
false
;;
esac
Replace true and false with the appropriate actions.
--
Chris F.A. Johnson <http://cfaj.freeshell.org>
===================================================================
Author:
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
--
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