Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 unix code
Index -> General Programming
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Fonzie




PostPosted: 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?
Sponsor
Sponsor
Sponsor
sponsor
HeavenAgain




PostPosted: 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
OneOffDriveByPoster




PostPosted: Fri Nov 16, 2007 9:21 pm   Post subject: Re: unix code

bash:
for i in "$@"
Display posts from previous:   
   Index -> General Programming
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: