OS515-Workbook6-part2 Flashcards
The bash shell expands certain command line metacharacters before…?
interpreting the command.
Tilde expansion expands tokens that begin with a…?
tilde (~) to users home directories.
Brace expansion expands tokens with …?
braces ({}) into multiple words, each of which contains a single word from the specified list.
mkdir {dir1,dir2,dir3}/{subdir1,subdir2}
mkdir dir1
mkdir dir1/subdir1
mkdir dir1/subdir2
…etc…
Command substitution expands text enclosed within…?
backticks (‘’) or “dollar parenthesis” ($()) into the output produced by the enclosed command.
VAR=COMMAND
FILES=`ls /etc` FILES=$(ls /etc)
Pathname Expansion ("File Globbing") Covered earlier and is also...?
a shell expansion.
Remember that expansion occurs before the program is…?
executed, so the program is given a set of matching files.
Pathname Expansion:
Character * match?
0 or more characters
Pathname Expansion:
Character ? match?
Exactly one characters.
Pathname Expansion:
Character […] match?
Exactly one of the included characters.
Pathname Expansion:
Character [^…]
Exactly one of the excluded characters.
See slide 8 for…?
command line expansion subtleties.
The bash shell internally implements certain simple commands which are closely related to the…?
to the shell’s behavior. These are referred to as builtin commands.
Shell aliases create apparent commands which…?
expand to arbitrary text.
The bash shell prompt can be…?
customized using the PSI variable.
Shell flags modify the …?
bash shell behavior.
Shell options offer more…?
bash shell configuration options.
Slide 11 shows…?
Slide Builtins.
Slide 12 shows…?
Aliases
Running commands.
Perform any shell expansions
v
Expand any aliases
v
If command is shell function, run the function.
v
If the command is built-in run it.
v
if the command is absolute run it (if allowed and exists)
v
Search PATH for command if allowed run it.
PS1…?
Default prompt.
PS2…?
Secondary prompt.
Sequence \a expansion?
audible terminal bell.
Sequence \d expansion?
date in “Weekday Month Date” format.
Sequence \h expansion?
the hostname up to the first “.”
Sequence \T expansion?
the current time in 12-hour HH:MM:SS format
Sequence \u expansion?
the username of the current user.
Sequence \W expansion?
the basename of the current working directory.
Sequence ! expansion?
the history number of this command.
Sequence $ expansion?
if the effective UID is 0, a #, otherwise a $.
Sequence \nnn expansion?
the character corresponding to the octal number nnn.
Shell Flags: The set Builtin Command:
Flag -f and its effect…?
Disable Pathname Expansion (Globbing)
Shell Flags: The set Builtin Command:
Flag -n and its effect…?
Read commands, but do not execute them (used for performing syntax checks on scripts).
Shell Flags: The set Builtin Command:
Flag -o optionname and its effect…?
Set the specified option. Some of the more common options include the following.
emacs Use emacs style command line key bindings
ignoreeof Do not exit shell when EOF (CTRL-D) is read
vi Use vi style command line key bindings
Shell Flags: The set Builtin Command:
Flag -v and its effect…?
Print commands as they are read (useful in debugging scripts)
Shell Flags: The set Builtin Command:
Flag -x and its effect…?
Print commands after expansions have been applied (useful in debugging scripts and examining shell expansions)
Shell Flags: The set Builtin Command:
Flag -C and its effect…?
Don’t allow the shell to clobber files on redirection.
Shell Flags: The set Builtin Command:
Examples…?
[madonna@station madonna]$ set -f
[madonna@station madonna]$ ls /etc/.conf
ls: /etc/.conf: No such file or directory
[madonna@station madonna]$ set +f
[madonna@station madonna]$ ls /etc/*.conf
/etc/aep.conf /etc/lftp.conf /etc/pnm2ppa.conf
Shell Options: The shopt Builtin Command:
Option cdspell and its effect…?
Attempt to correct minor misspellings of directory names when using the cd builtin command.
Shell Options: The shopt Builtin Command:
Option expand_aliases and its effect…?
Enable shell aliases.
Shell Options: The shopt Builtin Command:
Option extglob and its effect…?
Enable extended globbing pattern matching syntax.
Shell Options: The shopt Builtin Command:
Option nocaseglob and its effect…?
Do not consider case when applying file globbing.
Shell Options: The shopt Builtin Command:
Examples…?
[madonna@station madonna]$ shopt cdspell cdspell off [madonna@station madonna]$ shopt -s cdspell [madonna@station madonna]$ cd /ect /etc [madonna@station etc]$ ls -d /ect ls: /ect: No such file or directory [madonna@station etc]$ shopt -u cdspell [madonna@station etc]$ cd /ect -bash: cd: /ect: No such file or directory
Shell scripts are sourced with the …?
source or . commands.
Shell scripts are all executed in the same shell that…?
sources the script.
See slide 19 for …?
bash initialization.