section 8 scripting and text editors Flashcards
more difficult to use than nano, installed by default.
vi
Scripts start with what? Example?
!/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.
After writing a script, what must be done to make it work?
Use the chmod command to make it executable.
Allows multiple programs to be launched in a script line by line
& at the end of each line
Why is it good practice to list the full path for each line in a script?
In case something goes wrong you’ll be able to troubleshoot easier, less likely to cause errors than a relative filepath.
What is an environment?
A set of variables such as current directory, search path, etc.
What is an argument/parameter?
Variables that are passed to the script. They start with a $
Logical operator for OR
|| (two pipes)
Logical operator for AND
&& (two ampersands)
function
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
exit value
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