|
google site
|
|||||||
| Forums | Register | Blog | Man Pages | Forum Rules | Links | Albums | FAQ | Users | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
![]() |
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
$1 $2 $3 error !!!
Hi All, i need to use $1 , $2 etc.. but 1,2 ,3 etc must be dynamic. example: Code:
say=5
i=2
toplam=0
while [ $say -gt 0 ]
do
let toplam=toplam+$$i
let say=say-1
let i=i+1
echo "toplam=$toplam"
donei remarked error word with red colour. i tried it like "${$i}" and "$($i)" but also i took ERROR again ![]() what can i do? Thanx ---------- Post updated at 08:28 AM ---------- Previous update was at 08:27 AM ---------- bye the way, this code is in function and i give arguman to function. But argumans are dynamic. Last edited by pludi; 12-10-2009 at 08:41 AM.. Reason: code tags |
| Sponsored Links | ||
|
|
|
#2
|
|||
|
|||
|
See the "shift" command in your shell manual. You can then refer to each of the 5 parameters to the function as $1 . I guess that you are trying to add up the 5 parameters to the script. Code:
say=5
i=2
toplam=0
while [ $say -gt 0 ]
do
let toplam=toplam+$1
let say=say-1
let i=i+1
echo "toplam=$toplam"
shift
done
./scriptname 1 2 3 4 5
toplam=1
toplam=3
toplam=6
toplam=10
toplam=15
./scriptname 99 42 63 87 174
toplam=99
toplam=141
toplam=204
toplam=291
toplam=465 |
|
#3
|
|||
|
|||
|
Thanx so much my friend methly.
|
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| fssnap error :snapshot error: File system could not be write locked | aggadtech08 | Solaris | 2 | 09-15-2009 10:12 AM |
| Build Error: error: dereferencing pointer to incomplete type | katwala | UNIX for Dummies Questions & Answers | 8 | 04-17-2009 09:16 AM |
| Kernal panic error& setuproot:error mounting /proc&/sys | arjunreddy3 | Linux | 2 | 03-09-2009 11:10 PM |
| awk Shell Script error : "Syntax Error : `Split' unexpected | Herry | UNIX for Dummies Questions & Answers | 2 | 03-17-2008 10:16 AM |
| Error: Internal system error: Unable to initialize standard output file | firkus | UNIX for Dummies Questions & Answers | 2 | 10-25-2005 03:23 PM |