section 8 scripting and text editors Flashcards

1
Q

more difficult to use than nano, installed by default.

A

vi

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Scripts start with what? Example?

A

!/bin/bash - will use BASH to interpret the script.

A line specifying what shell the script is using (the program that interprets the script).

#!/bin/sh - more compatible across various Linux systems that may not use BASH.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

After writing a script, what must be done to make it work?

A

Use the chmod command to make it executable.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Allows multiple programs to be launched in a script line by line

A

& at the end of each line

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Why is it good practice to list the full path for each line in a script?

A

In case something goes wrong you’ll be able to troubleshoot easier, less likely to cause errors than a relative filepath.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is an environment?

A

A set of variables such as current directory, search path, etc.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is an argument/parameter?

A

Variables that are passed to the script. They start with a $

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Logical operator for OR

A

|| (two pipes)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Logical operator for AND

A

&& (two ampersands)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

function

A

list of commands grouped together that can be called upon as if it were a single command. don’t have to be called upon in order, can jump around

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

exit value

A

An exit value is using the exit command and a number is a handy way of signalling the outcome of your script. It mimics the way that bash commands output a return code. With bash commands the return code 0 usually means that everything executed successfully without errors. exit also makes your script stop execution at that point and return to the command line.
number between 0-255, can be used to specify why the script terminated, useful for troubleshooting cause of termination

exit $termcause

How well did you know this?
1
Not at all
2
3
4
5
Perfectly