From owner-freebsd-questions Wed May 14 07:29:17 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id HAA11332 for questions-outgoing; Wed, 14 May 1997 07:29:17 -0700 (PDT) Received: from mail.EUnet.hu (www.eunet.hu [193.225.28.100]) by hub.freebsd.org (8.8.5/8.8.5) with ESMTP id HAA11320 for ; Wed, 14 May 1997 07:28:46 -0700 (PDT) Received: by mail.EUnet.hu, id QAA04903; Wed, 14 May 1997 16:28:13 +0200 Received: (from zgabor@localhost) by CoDe.hu (8.7.5/8.7.3) id PAA00546; Wed, 14 May 1997 15:03:49 +0200 (MET DST) From: Zahemszky Gabor Message-Id: <199705141303.PAA00546@CoDe.hu> Subject: Re: parameter expansion To: freebsd-questions@freebsd.org (FreeBSD questions) Date: Wed, 14 May 1997 15:03:48 +0200 (MET DST) Cc: un_x@anchorage.net In-Reply-To: from Steve Howe at "May 14, 97 00:26:36 am" X-Mailer: ELM [version 2.4ME+ PL11 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-questions@freebsd.org X-Loop: FreeBSD.org Precedence: bulk > > 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"