[clug] sh scripts and =~ in csh
tony at bakeyournoodle.com
Tue Sep 11 03:59:51 GMT 2007
On Tue, Sep 11, 2007 at 12:32:31PM +1000, Andrew Janke wrote:
> Just "sh-ifying" and old csh script that has been lying about and
> cannot for the life of me remember the equivalent of this in sh...
> set answer = "yes"
> if ("$answer" =~ y*) then
> ie: what is the equivalent of =~?
If you're writing /sh/ scripts I don't think there is a nice one.
something like (untested):
if [ "$(echo "$answer" | sed -n -e '/y.*/ p')" == "$answer" ] ; then
Might work. However, if you're writing /bash/ sctipts I think you can
if [[ "$answer" =~ 'y.*' ]] ; then
linux.conf.au http://linux.conf.au/ || http://lca2008.linux.org.au/
Jan 28 - Feb 02 2008 The Australian Linux Technical Conference!
More information about the linux