bash $X++ sintax

Chris F.A. Johnson cfaj-uVmiyxGBW52XDw4h08c5KA at public.gmane.org
Thu May 25 18:19:48 UTC 2006


On Thu, 25 May 2006, Neil Watson wrote:

> What is the bash equivalent of the perl command
> $X++;

    If you mean to increment a variable, then the portable, POSIX way
    is:

X=$(( $X + 1 ))

    A little less portably, though still POSIX is:

: $(( X += 1 ))

    This works in bash, but is not POSIX compliant:

(( ++X ))

-- 
    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://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml





More information about the Legacy mailing list