CIS330 Linux Chapter 7 Working with the BASH Shell Part 2

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

A BASH shell has several variables in memory at any one time.

A BASH shell has several variables in memory at any one time.

tee

A __________________________ command is a filter command that takes information from Standard Input and sends that information to a file, as well as to Standard Output.

variable

A __________________________ is a reserved portion of memory containing information that might be accessed.

special

In addition to environment variables and user-defined variables, __________________________ variables are available when executing commands and creating new files and directories.

environment

Most variables in the shell are referred to as __________________________ variables because they are typically set by the system and contain information that the system and programs access regularly.

Redirection and piping can be combined together. Input redirection must occur at the beginning of the pipe and output redirection must occur at end of the pipe.

Redirection and piping can be combined together. Input redirection must occur at the beginning of the pipe and output redirection must occur at end of the pipe.

MYVAR="This is a sample variable." echo $MYVAR This is a sample variable.

The MYVAR command created a variable that is available to the current shell. The echo command displays the value of the variable.

PS1="This is a new prompt: #" echo $HOME echo $PWD echo $PATH

The PATH variable is searched in the order that the directories are listed. If the executable file is not in a directory listed in the PATH variable, the user must specify either the absolute or relative pathname to the executable file.

The PATH variable is searched in the order that the directories are listed. If the executable file is not in a directory listed in the PATH variable, the user must specify either the absolute or relative pathname to the executable file.

The PATH variable is searched in the order that the directories are listed. If the executable file is not in a directory listed in the PATH variable, the user must specify either the absolute or relative pathname to the executable file.

set

The __________________________ command lists the environment variables and their current values.

echo ?

The __________________________ command views the contents of a specified variable and uses the prefix $ shell metacharacter.

sed

The __________________________ filter command searches for a certain string of text and replaces that text string with another text string. Similar to find and replace in word

awk

The __________________________ filter command searches for patterns of text and perform some action on the text found. This command treats each line of text as a record in a database and each word in a line as a database field.

variable identifier

The __________________________ is the name of a variable.

PS1

The __________________________ variable represents the BASH shell prompt. To view the contents of this variable only, the user can use the echo command and specify the variable name prefixed with a $ shell metacharacter.

The awk command uses space or tab characters as delimiters for each field in a line. Most configuration files on Linux systems are delimited using the colon (:) character. To change the delimiter that the awk command uses, use the -F option to the command.

The awk command uses space or tab characters as delimiters for each field in a line. Most configuration files on Linux systems are delimited using the colon (:) character. To change the delimiter that the awk command uses, use the -F option to the command.

They can contain alphanumeric characters (0 - 9, A - Z, a - z), the dash (-) character, or the underscore (_) character. They must not start with a number. They are typically capitalized to follow convention.

The features of variable identifiers are the following:

The syntax of the sed filter command is s/search/replace/.

The syntax of the sed filter command is s/search/replace/.

set also

This command displays a list of the environment variables that are set by the BASH shell.

cat MacBeth | awk '/the/ {print $1, $3, $5}'

This command displays the first, third and fifth words only on lines of the MacBeth file that contains the word "the".

tail /etc/passwd | awk -F: '/tom/ {print $2, $6, $7}' QUIZ FRIDAY ENDS HERE: FSCHK CH6 AND CH 7 TILL HERE

This command displays the second, sixth and seventh words for lines that contain the word "tom" in the last 10 lines of the file. This works in Ubuntu 16.04 MATE.

echo $PS1

This command displays the value of the PS1 variable. The following is the code that we care about. [\u@h \W\$ \u - user \h - host name \W - name of the current directory

cat MacBeth | sed s/the/THE/g

This command searches each line of the MacBeth file for the word "the" and replaces it with the word "THE". It now replaces all of the strings "the" it finds globally in the whole document. g = global

cat MacBeth | sed s/the/THE/

This command searches each line of the MacBeth file for the word "the" and replaces it with the word "THE". It only replaces the first "the" it finds in each line.

cat MacBeth | sed /my/s/a/ABCDEF/g

This command searches each line of the MacBeth file that contains the string "my" and replaces all of the strings "a" with the string "ABCDEF".

cat MacBeth | sed 5,14s/i/ITISFORME/g

This command searches lines 5 through 8 of the MacBeth file for the string "i" and replaces them with the string "ITISFORME" globally.

cat MacBeth | sed /th/d

This command searches through the MacBeth file and deletes all of the lines that contain the string "th".

tr a A <prologue | sort | nl > newprologue

This command takes the prologue file and translates the "a"'s to "A"'s and then sorts the lines in alphabetical order and numbers them. The output is saved as a file called newprologue.

cat prologue | tr a A | sort | pr -d | tee newfile | less

This command takes the prologue file and translates the "a"'s to "A"'s and then sorts the lines in alphabetical order. In addition, it displays the file on the terminal double spaced and allows the user to view the results page-by-page. In addition, it uses the tee command to save a copy of the output as a file called newfile.

To change the value of a variable, the user can specify the variable name followed by the equal sign (=) and the new value.

To change the value of a variable, the user can specify the variable name followed by the equal sign (=) and the new value.

To create new variables, specify the variable identifier followed by equal sign and the new contents.

To create new variables, specify the variable identifier followed by equal sign and the new contents.

User-defined

__________________________ variables are custom variables that are defined by users.


Set pelajaran terkait

14.2.5 Controls and Frameworks Section Quiz

View Set

Georgia Principles of Real Estate

View Set

Money and Banking Chapter 1 (Possibly part of CH.2 also)

View Set

Exam 9 Women and Children Chapter35, (Adult Health 41, 42, 43)

View Set

Java Programming - Chapter 1 - Creating Java Programs

View Set

Professionalism and Leadership Test

View Set

World Civ-Chapter 19 Section 4,5

View Set