Unix/ Shell scripts

Hi,

I need to develop a function incrementor that increments a given number that is passed as an argument (this should use eval). so, am not able to get much info on eval by googling (perticularly on incrementing).
please if any one can help me out.

thanks in advance

Post whatever you have attempted so far. You are more likely to get assistance if you demonstrate that you have attempted something, and specify which shell etc you require assistance with.

And why the requirement to use eval ? Is this homework ?; Please ensure you have read and comply The UNIX and Linux Forums - Forum Rules

no,its not home work...

actually,..i tried in this way

set 2
echo "$1"
# here n may represent an expr value, in this case i want to display a $ value of n value with incrementation ( some where i require this)
n=1
echo $($n)
please help me out if u know

Geervani,

I do hope this is what you are trying to do?
The var. N specifies the parameter number to display.

#!/bin/ksh
N=2
echo $* |sed "s/ /\n/g" |grep -n "" |grep ^$N: |awk -F ':' '{print $2}'

Something like this? (It's bash which has arithmetics built-in.)

#!/bin/bash

inc()
{
    echo $(($1+1));
}

n=2
echo $n
n2=$(inc n)
echo $n2