Author |
Message |
Fonzie
|
Posted: Fri Nov 16, 2007 5:29 pm Post subject: unix code |
|
|
I wasn't sure where to put this so I hope it's in the right place.
I'm using a scripting language for the first time and I'm using the bash shell. I'm trying to get a loop to run until a datafile given in the command line has been read through. Here's my code:
for ((i=1; i<$#+1; i++))
do
while read line
do
echo $line
done < $i
done
So what I (incorrectly) think this program should do is output every line from every datafile. However the line "done < $i" seems to have a problem. How do I easily address a variable command line argument? |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
HeavenAgain
![](http://compsci.ca/v3/uploads/user_avatars/139122102045e603120b143.jpg)
|
Posted: Fri Nov 16, 2007 7:37 pm Post subject: RE:unix code |
|
|
have you tried removing $ sign?
in some languages it just gives the value of it
like
i = (current value)
so its not able to compare
i think ![Rolling Eyes Rolling Eyes](http://compsci.ca/v3/images/smiles/icon_rolleyes.gif) |
|
|
|
|
![](images/spacer.gif) |
OneOffDriveByPoster
|
Posted: Fri Nov 16, 2007 9:21 pm Post subject: Re: unix code |
|
|
|
|
|
|
|
![](images/spacer.gif) |
|