Deploy and execute basic bash scripts

Ace your homework & exams now with Quizwiz!

Shell environments and shell variables: PATH

-The PATH variable is an environment variable that contains an ordered list of paths that Unix will search for executables when running a command. Using these paths means that we do not have to specify an absolute path when running a command. -We add a new path to the PATH variable using the export command. EX: export PATH=/some/new/path:$PATH

Shell environments and shell variables: printenv

-printenv command is used to display all the environment variables.

Commenting

A comment is a human-readable explanation or annotation that is written in the shell script. -Adding comments to your Bash scripts will save you a lot of time and effort when you look at your code in the future. -hashtag ( # ) to put a comment down

Shell environments and shell variables: Local

A local variable is a variable that is present within the current instance of the shell. -Local variables — The bash shell has two types of environment variables: Local variables; Global variables. The local variable is visible in the shell -The local variable is visible in the shell, where it was defined only.

Shell expansions: $()

Command substitution is way of embedding a command into an output. -There are two methods of embedding a command: `<command>' and $(<command>) -The backtick is found on top-left under tilde ~

Shell expansions: ``

Command substitution is way of embedding a command into an output. -There are two methods of embedding a command: `<command>' and $(<command>) -The backtick is found on top-left under tilde ~

Shell expansions: ${}

Command substitution is way of embedding a command into an output. -There are two methods of embedding a command: `<command>' and $(<command>) -The backtick is found on top-left under tilde ~ -Number maybe

File globbing

File globbing is a feature provided by the UNIX/Linux shell to represent multiple filenames by using special characters called wildcards with a single file name. -You are searching for filenames using wildcards characters. which is called file globbing Ex: ls -l | grep ch* ls cfiles/*.? rm {*.doc, *.docx}

Shell environments and shell variables: Global

Global variables are also called as environment variables, which will be available to all shells. -A global variable is a variable with global scope, meaning that it is ... Within the OS's shell (ksh in Unix, bash in Linux, COMMAND. -The global variable is visible for any running process that runs from the shell.

Conditional statements: case

The case statement allows you to easily check pattern (conditions) and then process a command-line if that condition evaluates to true. -First argument or expression of the command line determine what is will do. -case statement is broken into stanzas -All case statement end with esac

Shell environments and shell variables: env

The command allows you to run another program in a custom environment without modifying the current one. -When used without an argument it will print a list of the current environment variables. -allow you to customize how the system works and the behavior of the applications on the system.

Shell environments and shell variables: export

The command sets environment variables. -We add a new path to the PATH variable using the export command. EX: export PATH=/some/new/path:$PATH

Shell environments and shell variables: set

The command sets or unsets shell variables. When used without an argument it will print a list of all variables including environment and shell variables, and shell functions. The set command assigns a value to a variable (or multiple values to multiple variables) -The SET command is used to set values that will be used by programs -unset command deletes shell and env variables

Looping constructs: for

The for loop operates in a different manner than until and while loop. -The until and while loops keep looping indefinitely until the specified condition is met. -for loop, loops a specific number of times -It uses seq command within create sequence of numbers to determine how many times it will loop. -seq 0 1 10 or {0..10..1}

Looping constructs: while

The while loop execute over and over until a specifed condition is no longer true. -While loop will keep processing over and over until the condition evaluates to false. While loop must have "done" at the end

Looping constructs: until

You can also use until loop it works in the opposite manner of while loop. -The until loop runs over and over as long as the condition is false. -As soon as the condition is true, it stops. -Done at the end of the until loop

Escaping characters

awk is application used to process text file -awk uses the same escape sequence to do character insertions as the echo command

Conditional statements: if

if is a command in Linux which is used to execute commands based on conditions. -If the condition evaluates to true (exit status 0), the command or commands directly under the test statement are executed. -The test command allow you to evaluate conditions using the syntax: test <expression> -The else statement indicates the commands to be executed if the original test condition is true. -The elif statement open another test condition. -All if statements end in fi.

Shell environments and shell variables: echo

is a command that outputs the strings it is being passed as arguments. -It is a command available in various operating system shells and typically used in shell scripts and batch files to output status text to the screen

#

scripting or in a file or any file to comment out


Related study sets

Lab 16-2: Configuring Windows Defender Firewall

View Set

Persistent Storage in Android Applications

View Set

Interpersonal Communication Final (Exam 2 Q's)

View Set

IBA Final Practice I-A, I-B, I-C

View Set

EAQ- Lewis Med Surg CH.27, Nursing Management: Upper Respiratory Problems- Problems of Pharynx, Trachea, and Larynx

View Set

EXPH Lab Exam 1: Post Lab Questions

View Set