Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 14 May 1997 15:03:48 +0200 (MET DST)
From:      Zahemszky Gabor <zgabor@CoDe.hu>
To:        freebsd-questions@freebsd.org (FreeBSD questions)
Cc:        un_x@anchorage.net
Subject:   Re: parameter expansion
Message-ID:  <199705141303.PAA00546@CoDe.hu>
In-Reply-To: <Pine.BSF.3.95q.970514002319.4631B-100000@aak.anchorage.net> from Steve Howe at "May 14, 97 00:26:36 am"

next in thread | previous in thread | raw e-mail | index | archive | help
> 
> t=file.gz.tar.gz
> echo ${t%.gz}
> echo ${t%%.gz}
> 
> i've been trying to figure out the difference between
> using 1 or 2 "%" in my expansions, but haven't had any luck!
> whether 1 or 2, i can't see any difference.
> -------------------------------------------------------------------------

Well, it has any difference, if you use such joker characters, that match
more than one characters (of course, there is only one: *):
$ echo $MAIL
/var/mail/zgabor
$ echo ${MAIL%/*}
/var/mail
$ echo ${MAIL%%/*}

$

or another one:
$ echo {MAIL#*/}
var/mail/zgabor
$ echo ${MAIL##*/}
zgabor
$

Bye, Gabor

PS: is it works in your sh?  On my 2.1.5 from sh, I got only:
Syntax error: Bad substitution

--
#!/bin/ksh
Z='21N16I25C25E30, 40M30E33E25T15U!' ;IFS=' ABCDEFGHIJKLMNOPQRSTUVWXYZ ';set $Z;for i { [[ $i = ? ]]&&print $i&&break;[[ $i = ??? ]]&&j=$i&&i=${i%?};typeset -i40 i=8#$i;print -n ${i#???};[[ "$j" = ??? ]]&&print -n "${j#??} "&&j=;typeset +i i;};IFS=' 0123456789 ';set $Z;X=;for i { [[ $i = , ]]&&i=2;[[ $i = ?? ]]||typeset -l i;X="$X $i";typeset +l i;};print "$X"



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199705141303.PAA00546>