mirror of
https://codeberg.org/Mo8it/How_To_Linux.git
synced 2024-11-24 21:01:35 +00:00
Explain comments and read
This commit is contained in:
parent
2c435c1713
commit
08c686d8cf
1 changed files with 10 additions and 2 deletions
|
@ -192,9 +192,17 @@ We did define a temporary variable `USER` with the value `Tux`. This temporary v
|
|||
|
||||
You can use temporary variables not only to overwrite environment variables. These are basically variables that can be used by the program that you specify after their definition.
|
||||
|
||||
<!-- Comments -->
|
||||
## Comments
|
||||
|
||||
<!-- TODO: read -->
|
||||
In our first bash script, you can find three lines starting with a hashtag `#`. Two lines are comments, the shebang `#!` is an exception as a special comment at the beginning of a file that is not ignored while running the script. All other lines that start with `#` are comments that are ignored by the computer. Comments are only for humans to explain things.
|
||||
|
||||
Especially in long scripts, you should write comments to explain what the script and its "non trivial sections" do.
|
||||
|
||||
## User input
|
||||
|
||||
In a script, you can ask for user input. To do so, you can use the command `read`.
|
||||
|
||||
In our first bash script, we use `read` to take the answer of the user. The input is then saved in the variable `ANSWER`. You can choose a different name for this variable. After the line with `read`, you can use the variable storing the input as a normal variable.
|
||||
|
||||
<!-- TODO: if -->
|
||||
|
||||
|
|
Loading…
Reference in a new issue