Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions concepts/variables/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ bash is going to call the **command** `x` with the **two arguments** `=` and `10
~~~~

Variables can also be called _parameters_.
The two terms will be used interchangably in this document.
The two terms will be used interchangeably in this document.

Some important parameters used by or set by bash include:

Expand Down Expand Up @@ -204,7 +204,7 @@ Bash has many builtin facilities to manipulate variables and strings so that you
```bash
text="Hello world!"
echo "${text//[aeiou]/X}"
# => HXllX wXrld!"
# => HXllX wXrld!
```

There are many other interesting parameter expansions: extract a substring, get the string length, _assign_ a default value, remove text from the start or end of the value, and more.
Expand Down
4 changes: 2 additions & 2 deletions concepts/variables/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ bash is going to call the **command** `x` with the **two arguments** `=` and `10
~~~~

Variables can also be called _parameters_.
The two terms will be used interchangably in this document.
The two terms will be used interchangeably in this document.

Some important parameters used by or set by bash include:

Expand Down Expand Up @@ -204,7 +204,7 @@ Bash has many builtin facilities to manipulate variables and strings so that you
```bash
text="Hello world!"
echo "${text//[aeiou]/X}"
# => HXllX wXrld!"
# => HXllX wXrld!
```

There are many other interesting parameter expansions: extract a substring, get the string length, _assign_ a default value, remove text from the start or end of the value, and more.
Expand Down
4 changes: 2 additions & 2 deletions exercises/concept/lasagna/.docs/hints.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
## 2. Calculate the remaining oven time in minutes

- The first command-line argument is the [positional parameter][positional] `$1`.
- Use a default value to handle a missing argument: `${1:-0}`.
- Use the `${name:-default}` form to handle a missing argument: it works with positional parameters too.
- [Arithmetic expansion][arithmetic] expands to the result of a calculation: `result=$(( 7 - 2 ))`.
- Inside `$(( ))`, you can use variable names without the `$`.

## 3. Calculate the preparation time in minutes

- The second command-line argument is `$2`.
- Remember to provide a default for a missing argument.
- Use `*` to multiply: `$(( a * b ))`.
- Use `*` to multiply inside `$(( ))`.
- Store the minutes per layer in a variable, so the number 2 has a name.

## 4. Calculate the total working time in minutes
Expand Down
8 changes: 4 additions & 4 deletions exercises/concept/lasagna/.docs/instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ According to the cookbook, the expected oven time is 40 minutes.
Store this value in a variable, and print it:

```text
$ bash lasagna.sh 18 3
Expected minutes in oven: 40
```

Expand All @@ -37,11 +38,8 @@ Store the actual minutes in the oven (the first argument) in a variable.
Then calculate how many minutes the lasagna still has to remain in the oven, based on the expected oven time from the previous task.
Print it on the next line:

```bash
bash lasagna.sh 18 3
```

```text
$ bash lasagna.sh 18 3
Expected minutes in oven: 40
Comment thread
glennj marked this conversation as resolved.
Resolved
Remaining minutes in oven: 22
```
Expand All @@ -54,6 +52,7 @@ Store the number of layers (the second argument) in a variable, and store the mi
Print the preparation time on the next line:

```text
$ bash lasagna.sh 18 3
Expected minutes in oven: 40
Remaining minutes in oven: 22
Preparation time in minutes: 6
Expand All @@ -66,6 +65,7 @@ This is the sum of the preparation time and the time the lasagna has spent in th
Print it on the last line:

```text
$ bash lasagna.sh 18 3
Expected minutes in oven: 40
Remaining minutes in oven: 22
Preparation time in minutes: 6
Expand Down
4 changes: 2 additions & 2 deletions exercises/concept/lasagna/.docs/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ bash is going to call the **command** `x` with the **two arguments** `=` and `10
~~~~

Variables can also be called _parameters_.
The two terms will be used interchangably in this document.
The two terms will be used interchangeably in this document.

Some important parameters used by or set by bash include:

Expand Down Expand Up @@ -206,7 +206,7 @@ Bash has many builtin facilities to manipulate variables and strings so that you
```bash
text="Hello world!"
echo "${text//[aeiou]/X}"
# => HXllX wXrld!"
# => HXllX wXrld!
```

There are many other interesting parameter expansions: extract a substring, get the string length, _assign_ a default value, remove text from the start or end of the value, and more.
Expand Down
2 changes: 1 addition & 1 deletion exercises/concept/lasagna/.meta/design.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ The goal of this exercise is to introduce variables in bash scripts.
- Use descriptive, non-ALLCAPS variable names.
- Read command-line arguments through positional parameters.
- Provide a default value with `${name:-default}`.
- Capture the output of a command in a variable with command substitution.
- Do integer arithmetic with arithmetic expansion.

## Out of scope

- Command substitution.
- Other arithmetic contexts, such as the `(( ))` conditional.
- Arrays.
- Functions and `local` variables.
Expand Down
Loading