![]() |
Need help in 2 scripts in bash
Hi! I need your help.
1) How to make a script which writes its argument in the other way round. I mean if arguments are "2 3 4 5" the script writes "5 4 3 2" 2) How to make a script which reads a file which consinst of numbers (one number in one line) and writes the sum of those numbers. E.G. the content of file: ------ 3 7 6 4 ------ in this case the script should write: 20 Please help me |
for the first will
:
echo "$9 $8 $7 $6 $5 $4 $3 $2 $1"Second: :
#! /bin/bash |
For the first script:
:
echo "$9 $8 $7 $6 $5 $4 $3 $2 $1"For the second: This is what i looked for :) thanx a lot. I didn't know that commend: :
((=$b))I even wrote simpler way (also working) :
THANX a lot and if you could help me with the first script :) |
yea I know what you mean.
You'll have to use shift somewhere then. |
for the first one, you could probally use a loop of some kind to keep looping, till you get to the end.
|
yeah i know but i tried with for and while but no idea :(
|
re: reverse
for the first one...
I din't know, but is there a way to take the first argument and the rest of arguments? that way you can do it recursively: :
if [ -n $1 ] |
| All times are GMT -5. The time now is 4:58 PM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC