Basic Script Constructs

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/31

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 6:36 PM on 3/24/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

32 Terms

1
New cards

What must you understand to develop a script in a particular language?

The syntax of the language.

2
New cards

What is the difference between a syntax error and a logical error?

Syntax error prevents the script from running; logical error could cause it to operate differently from what was intended.

3
New cards

Why add comments in code (best practice)?

Assist with maintaining it.

4
New cards

How is a comment line treated by the compiler or interpreter?

Ignored.

5
New cards

What indicates a comment line in Bash (and several other languages)?

Hash or pound sign (#).

6
New cards

What is a variable in a script?

A label for some value that can change as the script executes.

7
New cards

How are variables usually set up at the start of the routine where they’re used?

Declared, defined as a particular data type, and given an initial value.

8
New cards

What is an argument/parameter in a script?

A variable that is passed to the script when it is executed.

9
New cards

How does Bash refer to arguments by position?

$1, $2, and so on.

10
New cards

What is a constant in a script?

A label for a value that remains constant throughout the execution of the script.

11
New cards

In normal execution, how are statements processed in a script?

In turn from top to bottom.

12
New cards

What are the two main types of conditional execution?

Branches and loops.

13
New cards

What is a branch?

An instruction to execute a different sequence of instructions based on the outcome of some logical test.

14
New cards

In the Bash if example, what does -z test?

Whether the first positional parameter ($1) is unset or empty.

15
New cards

Why enclose the variable in double quotes in the condition?

Safer way to treat the input from the user (supplied as the argument).

16
New cards

Why use double quotes in echo "Hello $1" instead of single quotes?

Allows the variable to expand to whatever it represents.

17
New cards

What is a loop?

Allows a statement block to be repeated based on some type of condition.

18
New cards

When is a For loop used?

When the number of iterations is predictable.

19
New cards

What do While/Until loops do?

Repeat an indeterminate number of times until a logical condition is met.

20
New cards

In the Until ping example, what does &/dev/null do?

Stops the usual ping output from being written to the terminal by redirecting it to a null device.

21
New cards

What should you ensure about loops in your code?

No unintended or infinite loops.

22
New cards

What does a logical test resolve to?

TRUE or FALSE.

23
New cards

What does == (or -eq) mean?

Is equal to (returns TRUE if both conditions are the same).

24
New cards

What does != (or -ne) mean?

Is not equal to (returns FALSE if both conditions are the same).

25
New cards

What do && and || mean in logical tests?

&& AND: if both conditions are TRUE, whole statement TRUE; || OR: if either condition is TRUE, whole statement TRUE.

26
New cards

What does a loop do in a script?

Repeats a section of the script based on some type of circumstance.

27
New cards

What kind of loop runs for a specific number of times?

For loop.

28
New cards

What kind of loop runs for an unknown number of times until a logical condition is not true anymore?

Until loop.

29
New cards

What kind of loop runs for an unknown number of times, but only while a logical condition is true?

While loop.

30
New cards

In the washing dishes example, what does a for loop look like?

Wash 5 plates and then stop.

31
New cards

In the washing dishes example, what does an until loop look like?

Washing dishes until all the plates are done; once there are no plates and you're left with just pots and pans, move on.

32
New cards

In the washing dishes example, what does a while loop look like?

Washing as long as there are dishes on the countertop; as soon as there are no dishes on that counter, you're done.

Explore top notes

Explore top flashcards

flashcards
Microbio Final: Week 12
50
Updated 684d ago
0.0(0)
flashcards
APUSH unit 5/6
39
Updated 1113d ago
0.0(0)
flashcards
Macbeth Quotes
28
Updated 528d ago
0.0(0)
flashcards
Alabama's Driver Test
80
Updated 1206d ago
0.0(0)
flashcards
AP LANG VOCAB UNIT 2
20
Updated 802d ago
0.0(0)
flashcards
Spanish II - Air Travel
62
Updated 1133d ago
0.0(0)
flashcards
Ecología
21
Updated 1020d ago
0.0(0)
flashcards
Biol 1031 Practical
56
Updated 1126d ago
0.0(0)
flashcards
Microbio Final: Week 12
50
Updated 684d ago
0.0(0)
flashcards
APUSH unit 5/6
39
Updated 1113d ago
0.0(0)
flashcards
Macbeth Quotes
28
Updated 528d ago
0.0(0)
flashcards
Alabama's Driver Test
80
Updated 1206d ago
0.0(0)
flashcards
AP LANG VOCAB UNIT 2
20
Updated 802d ago
0.0(0)
flashcards
Spanish II - Air Travel
62
Updated 1133d ago
0.0(0)
flashcards
Ecología
21
Updated 1020d ago
0.0(0)
flashcards
Biol 1031 Practical
56
Updated 1126d ago
0.0(0)