tobold.org

correct • elegant • free

△ comp.unix.shell △

◅ Add a blank space to the beginning of each line

Du command does not work on my system ▻

Newbie Question? Repeated Incrementing in sh

In article <3770E247.2995F422@mitre.org>,
Boris Klimovitsky  <bklimov@mitre.org> wrote:
>   FOO=`expr $FOO + 1` does the increment, but I'd like to encase that in
>a... well, I don't know, so long as whenever I evaluate that whatever,

A function, supported in all but the most ancient Bourne shells.

    inc() { FOO=`expr $FOO + 1`; }

>just be the command but to also contain the new value of FOO so that I
>could use the variable $INC and it'd return the incremented value.

    inc() { FOO=`expr $FOO + 1`; echo $FOO; }

Tim.
--
Tim Goodwin   | `I can't believe that someone is releasing
University of | something called "Unix" without something
Leicester, UK | called "/bin/sh".' -- Randal L. Schwartz

Original headers:

From: tjg@ltpcg.star.le.ac.uk (Tim J Goodwin)
Newsgroups: comp.unix.shell
Subject: Re: Newbie Question? Repeated Incrementing in sh
Date: 23 Jun 1999 15:07:39 +0100
Organization: University of Leicester, UK
Message-ID: <7kqpnb$ij$1@ltpcg.star.le.ac.uk>
References: <3770E247.2995F422@mitre.org>

△ comp.unix.shell △

◅ Add a blank space to the beginning of each line

Du command does not work on my system ▻