Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve the 2.4 Loops section. #104

Open
2bitninja opened this issue Oct 26, 2023 · 0 comments
Open

Improve the 2.4 Loops section. #104

2bitninja opened this issue Oct 26, 2023 · 0 comments

Comments

@2bitninja
Copy link

2bitninja commented Oct 26, 2023

I see two issues with your for loops section.

  1. Typo; In your 1st example. You use "end" to end the for loop, that is wrong it should be "done".
  2. It would be better to show some working examples

Instead of this:

for name [in list]
do
  statements that can use $name
done

How about doing it this way:

for name in one two
do echo $name
done

Example output:

one
two

Anther for loop example:

more list.txt
one
two
for name in $(more list.txt)
do echo $name
done

Example output:

one
two

Currently a user of the can't just cut and past the code into there terminal to run. This way they can do that to test and learn how it works.

Also maybe add a read line section to the while loop section.
Example:

more list.txt | while read line
do
  echo "$line"
done

This kind of loop is good for varibles with spaces in.

I can do a pull request if you want and do it for you, just let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant