It's UWAweek 48

help2003/help4407

This forum is provided to promote discussion amongst students enrolled in Open Source Tools and Scripting.

Please consider offering answers and suggestions to help other students! And if you fix a problem by following a suggestion here, it would be great if other interested students could see a short "Great, fixed it!"  followup message.

How do I ask a good question?
Displaying the 4 articles in this topic
Showing 4 of 564 articles.
Currently 4 other people reading this forum.


 UWA week 18 (1st semester, week 9) ↓
SVG not supported

Login to reply

👍?
helpful
9:23pm Mon 2nd May, James O.
Edited: 8 mins later

It's ok I figured it out


SVG not supported

Login to reply

👍?
helpful
9:23pm Mon 2nd May, James O.
Edited: shortly thereafter

#!/bin/bash lines=0 for i in file1 ; do lines=$((lines + 1)) done Can someone explain why my code needs a semicolon in the for loop? I've spent ages looking at the lectures and code online and never heard or saw an example of this being needed.


SVG not supported

Login to reply

👍?
helpful
9:23pm Mon 2nd May, James O.

#!/bin/bash lines=0 for i in file1 ; do lines=$((lines + 1)) done Can someone explain why my code needs a semicolon in the for loop? I've spent 3 hours researching and literally never heard or saw an example of this being needed.


SVG not supported

Login to reply

👍?
helpful
9:38pm Mon 2nd May, Michael W.

"James Osborne" <23*7*3*[email protected]*u*e*t*u*a*e*u*a*> wrote:
> #!/bin/bash > lines=0 > > for i in file1 ; do > lines=$((lines + 1)) > done > > Can someone explain why my code needs a semicolon in the for loop? I've spent 3 hours researching and literally never heard or saw an example of this being needed.
Hi James, If the "do" was below the "for" there is no need of a semicolon (which is how I set it out in my examples). When it's on the same line it gets confused as to whether the do is actually one of the things the for loop is iterating over. I therefore think it's clearer to have those things above, and the do on the next line. Cheers MichaelW

The University of Western Australia

Computer Science and Software Engineering

CRICOS Code: 00126G
Written by [email protected]
Powered by history
Feedback always welcome - it makes our software better!
Last modified  1:17AM Sep 14 2022
Privacy policy