[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] Built-in method for searching variable strings
From: |
Chet Ramey |
Subject: |
Re: [Help-bash] Built-in method for searching variable strings |
Date: |
Sat, 01 Nov 2014 17:39:48 -0400 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 |
On 11/1/14 11:34 AM, asem nofal wrote:
> Hello guys, i have searched for a built-in method for searching variables
> for sub strings but i have not found any built-in support for that , so i
> think that you should take that in consideration in the later release,
> since it's very common and vital process
foo=substring
sub=str
case $foo in
*"$sub"*) echo found substring ;;
*) echo didn\'t ;;
esac
if [[ $foo == *"${sub}"* ]]; then
echo found substring
else
echo didn\'t
fi
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU address@hidden http://cnswww.cns.cwru.edu/~chet/