CS 307: UNIX PROGRAMMING ENVIRONMENT REVIEW FOR EXAM 2 Prof. Michael J. Reale Fall 2014
EXAM 2 OVERVIEW
Exam 2 Material Exam 2 will cover the following: REVIEW slides from (8) to (17) (INCLUSIVE) THIS MEANS IT OVERLAPS WITH MATERIAL FROM THE FIRST EXAM!!! REVIEW 08 (both parts) and 09 Questions from Exam 1 pertaining to 08 and 09 Quizzes 3 and 4 VARIABLE practice REGEX practice It may also cover anything we ve touched on in the katas or labs
This Slide Deck This slide deck includes: REVIEW slides 08 through 17 inclusive Quiz overview 3-4 It does NOT include: Variable Practice Regex Practice The Katas from 08 through 17 includes The last 3 will be separate slides posted on the website
REVIEW (8) (Both parts) Advanced Shell Usage: Variables
Two Shell Families Bourne family (including sh, bash, and ksh) C-Shell family (including csh and tcsh) http://image.tmdb.org/t/p/original/6a74oazarlnndhk9sdilbuu2jyj.jpg https://www.sciencenews.org/sites/default/files/4910
What shell am I using? echo $0 Shell you are currently using echo $SHELL Default shell
Shell: Interactive AND Non-Interactive Interactive shell User submitting commands / getting feedback Login shells Non-interactive shell Shell runs shell script and terminates when done
Processes Process a specific instance of a program that is executing Contains information about the running program Can have multiple instances of same program each instance is its own process
ps command ps Shows the currently running processes By default, only shows your processes ps a Shows ALL currently running processes attached to a terminal
Parents and Children Example: run vi from your shell The shell process is the parent process (or parent) The vi process is the child process (or child)
Variables and Environment Variable thing that holds information Name identifier for the variable Value data stored in the variable Environment table of variables a process has access to
Variables in Unix Name Only letters, numbers, and underscore Must begin with letter or underscore Value almost always character string
Variables in Unix Can do the following with variables Create them Get value from them Change value Destroy them
Variables in Unix Two types of variables in Unix: Environment variables Shell variables
Environment and Shell Variables Environment variables Variables part of process s environment Similar to global variables in programming Passed from parent process to child process Shell variables Local to the currently running shell NOT passed down to child processes
Listing Variables env lists all environment variables set lists all shell variables
Printing the Value of a Variable Use $ to get value and echo command Example: echo $SHELL To be very clear, use curly braces {} Example: echo ${SHELL}
General Variable Information Environment variables only propagate DOWN the process tree (values do NOT go up the tree) Some variables have means as both local (shell) variables and global (environment) variables Bourne family vs. C-Shell family on how to handle this
C-Shell Family Variables A variable is either local OR global Shell variable local By convention, lowercase set myvar= Hello unset destroy shell variable Environment variable global By convention, UPPERCASE setenv MYVAR Hello unsetenv destroy environment variable Exception: certain special variables (both global and local copies)
Bourne Family Variables A variable is either local or local+global Shell variables local MYVAR= Hello new variable = shell variable by default Environment variables local AND global export MYVAR makes shell variable environment variable (local+global) export MYVAR= Hi set and export at same time ALL variables UPPERCASE names by convention unset destroys variable
Printing Variables env set Both shell families: prints all environment variables C-Shell: print all shell variables Bourne: print all shell variables AND environment variables (environment variables = both)
PATH variable PATH list of directories shell searches for command Bourne environment variable C-Shell dual shell/environment variables (path/path)
Controlling Shell Behavior C-Shell use shell variables Bourne use shell options set o (turn on) or set +o (turn off) Commands by themselves display options
REVIEW (9) Quoting/Escaping, Command Substitution, and Search Path
Metacharacters Certain characters have special meaning in the shell Examples: $ ;? * To print characters, must quote/escape them
\, Strong Quotes, and Weak Quotes \ (backslash) = escape character Works on anything (single quotes) = strong quotes Escapes/quotes everything (double quotes) weak quotes Quotes everything EXCEPT $ (dollar), ` (backquote), and \ (backslash)
Command Substitution ` (backquote) command substitution Example: set myshell=`basename ${SHELL}` NOTE: Must use backquotes on both ends!
Search PATH PATH variable shell searches in these directories for commands; stops when command found To add to path (ex: $HOME/bin): Bourne: export PATH= $PATH:$HOME/bin C-Shell: set path = ($path $HOME/bin) Can also add current directory. (Dot) Add on end DO NOT ADD AT ALL AS ROOT USER!
REVIEW (10) Streams, Pipes, and Redirection
Unix Philosophy Simple tools that do one thing very well Chain them together to do more complex things
Filters Filter program that can: Take input from any source Write output to any target Chained together to do more complex tasks
Streams Stream = source or destination of data Three streams are available to all programs: Standard Input (0, STDIN) Regular program input Standard Output (1, STDOUT) Regular program output Standard Error (2, STDERR) Program error output
Redirection Redirect streams get input from file OR send output to file > Redirect STDOUT to file (overwrite file) >> Redirect STDOUT to file (append to file) < Redirect file to STDIN
Clobbering Clobbering overwriting file because of redirect To prevent clobbering: C-Shell: set noclobber (turn off unset noclobber) Bourne: set o noclobber (turn off set +o noclobber) To override noclobbering: >! E.g., echo Howdy >! myfile
Piping Piping Chaining commands together (output of first command input of second) Send STDOUT of one command as STDIN to another with the (pipe) symbol First must write to STDOUT; second must read from STDIN
Tee tee sends data to STDOUT, but also saves data to a file Example: df grep da0 tee fs df grep da0 tee STDOUT fs
Sequence of Commands Separate commands by ; Performs a sequences of commands No input/output shared; no direct relationship
Grouped Commands Grouped commands: (command1; command2) Sequence of commands run in sub-shell Creates a new shell temporarily Output of all commands combined: E.g., (echo Today is `date` ; cal ) > mycal
File Descriptors File descriptor numerical identifier for every input/output within a Unix process Three predefined file descriptors provided to all Unix processes: 0 STDIN 1 STDOUT 2 STDERR
The Bourne Redirection Can redirect with file descriptor and <, >, or >> command 0< inputfile Redirect STDIN command 1> outputfile Redirect STDOUT command 2> errorfile Redirect STDERR
The Bourne Combination Redirect both STDOUT and STDERR ALL BOURNE SHELLS: command 1> outputfile 2>&1 MUST do 1> FIRST, then 2>&1 BASH: &> or >& command &> outputfile If appending: command >> outputfile 2>&1
C-Shell Redirection Redirect both STDOUT and STDERR, use >& E.g., sort >& output Redirect ONLY STDERR, need to use subshell: E.g., (sort > output) >& errors
REVIEW (11) Filters Overview
Filters Filter program that can: Take input from any source Write output to any target Simple tools chained together to do more complex tasks
Common Filters cat = simplest filter just prints data head = display lines from beginning of a file tail = display lines from end of a file grep = finds matching patterns (grep pattern) ^ = line begins with $ = line end with
Common Filters (continued) cut = cut out columns of data -d delimiter (defaults to tab) -f field -c cut at character positions sort = sort lines of text files uniq = filter out repeated lines in a file Must be sorted before showing unique values wc = counts words, lines, characters, and/or bytes -l line count
Comparing Files cmp compares two files byte by byte Usually used for binary files comm shows lines that the same, only in one file, or only in the other file (shows 3 columns) FILES MUST BE SORTED diff compares unsorted (text) files line by line Gives instructions to turn first file into second file Combined with patch to apply (and undo) changes Very useful for code projects
REVIEW (12) History and Aliases
History List History List where shell saves command history Each command event with event number Bourne family: fc commands C-Shell family: history and! Commands Bash: both
Bourne History Commands Bourne: Display fc l Re-execute event number 24 fc s 24 Re-execute last command fc s Replace pattern and re-execute number fc s pattern=replacement number Replace pattern and re-execute last fc s pattern=replacement Bonus: fc = fix command
C-Shell History Commands C-Shell: Display history Re-execute event number 24!24 Re-execute last command!! Replace pattern and re-execute!number:s/pattern/replacement Replace pattern and re-execute last ^pattern^replacement
Saving History Is history saved and restored after logging in again? Bourne: yes C-Shell: only if the shell variable savehist is set Need to tell it how many commands to save set savehist=30
Setting History Size Bourne: HISTSIZE variable export HISTSIZE=50 C-Shell: history shell variable set history=50
Alias Alias = name you give to a command or list of commands Bourne: alias name=commands No spaces between name, =, and commands C-Shell: alias name commands No equal sign NOTE: Use single quotes on commands
Alias Change value by redefining alias See current value alias name See ALL aliases alias Remove alias unalias name Remove ALL aliases Bourne: unalias a C-Shell: unalias *
Startup Files and Aliases Aliases NOT saved when you log out Also do NOT propagate down to child shells Ergo, usually define aliases in shell startup files
Suspending an Alias To suspend an alias temporarily, use the escape character (\) \name
REVIEW (13) Find Command
find Command find path test action Find files/folders in a directory tree Find executes a 3-step process: 1) Path: find looks in each path listed Searches entire directory tree in each path 2) Test: For each file, applies the tests you specify Goal = create list of files matching criteria 3) Action: once search complete, carries out actions specified on each file in list
Paths You can specify multiple paths: Example: find /bin /sbin /usr/bin name b* Prints out all files and directories in /bin, /sbin, and /usr/bin that begin with the letter b
Tests Most basic tests -type looks for a type of file -type d = directory -type f = ordinary file -name pattern matches name to pattern Can use wildcards (?,*,[]), but must single-quote them Case-sensitive (to ignore case, use iname) Negate test with! before test Must escape with \! or!
Actions Common actions: -print prints (default) -fprint file print to file -ls display long directory listing -fls file ls to file -delete deletes the found files Can have multiple actions
-exec and ok Actions -exec command {} \; Allows you to execute any command on the pathname command = the command you wish to execute {} = placeholder for file pathname May have to quote: {} \; = needed to end command; must be escaped -ok same as exec, but asks before executing command
xargs Command xargs Separate program that runs any command you specify on arguments from STDIN Use pipe to connect it to output from find
REVIEW (14) Advanced chmod (and some extra material)
chmod Advanced chmod who=permissions filename u = user (owner), g = group, o = others (world), a = all r = read, w = write, x = execute Can also subtract and add permissions: chmod who+permissions filename chmod who-permissions filename
chmod Advanced (cont.) Can set permissions of one entity equal to another chmod who=someoneelse filename Can do multiple things at once: E.g., chmod u+w,o-x myfile Can also set user ID: E.g., chmod u+s myprogram
rm vs. rmdir rm Removes files Removes directories using r option (recursive delete) This will delete empty OR non-empty directories rmdir ONLY removes empty directories
mv Command mv Used to move AND rename files Rename use different filename for destination E.g., mv file1 file2 Renames file1 to file2
del Command Actually a DOS command Happens to be aliased to rm on Fang HOWEVER, you cannot assume this all the time!
[] vs. {} [ab] Matches SINGLE characters (or range of characters) This will match character a OR character b {ab} Matches STRINGS separated by commas This will match string ab
Wildcards in [] and {} [a*,b*] Wildcards NOT interpreted in square braces [] This is interpreted as character a OR character * OR character, OR character b OR character * {a*,b*} Wildcards interpreted in curly braces {} This will fit files that begin with a or b
Using Metacharacters REMEMBER: In general, to treat a metacharacter as an actual character to match, use quoting/escaping! touch A* touch A* touch A\*
[^] Wildcard [^] Negates pattern that inside square brackets E.g., ls [^ab]* Find files that do NOT begin with a or b
Hard vs. Soft Links Hard links Can ONLY point to file inodes in the SAME filesystem Soft links Points to path of files OR directories These could be in the same OR a different filesystem
REVIEW (15) Process Fundamentals
Processes Defined Process Instance of a program that s running Includes program data and info about running program Each has a process ID (PID) and entry in process table Kernel manages processes and process table
Scheduler Scheduler Service in the kernel Maintains list of processes waiting to run Determines who gets to run next Chooses a process, lets it run for a time slice, then pauses process and picks another Processing time = CPU time
System Calls System Calls Allow processes to access kernel services E.g., file I/O, creating processes, etc. Used in programming Lots of system calls (200-300), but usually only a few really important ones
Process-Related System Calls The most important process-related system calls are: fork creates copy of current process exec changes the program the process is running wait pause until another process is finished exit terminates a process With one notable exception, every process is created by another process
The Shell Again Your shell is just another process To see the process ID of your current shell: echo $$
Internal and External Commands Commands can be: Internal built into shell; not really separate programs E.g., history External separate programs; shell creates processes to run them
Running External Commands The shell takes the following steps to run an external command: 1) parent (shell) calls fork Creates child process that is a copy of the current shell 2) child calls exec Changes program of child process from shell to desired program 3) parent (shell) calls wait Parent pauses itself until child finishes running 4) child calls exit Child finishes running, and the parent (shell) starts running again
Running External Commands Example: who
Zombie Process Zombie process What s left after a process dies and resources are deallocated Still has entry in process table When parent wakes up tells kernel to remove entry http://media.pcgamer.com/files/2010/11/pvz_zombie_suit.png
Orphan Process Orphan process When parent dies unexpectedly and child continues to execute Automatically adopted by process #1 (init process) Init will kill zombie orphans
Bad Parenting If the parent does not call wait, zombie child will never die To fix: Kill parent Zombie child becomes orphan zombie Init process adopts and kills orphan zombie
The Idle Process Idle Process (Process #0) Creates without forking near end of boot procedure by kernel Performs some important functions Forks to create process #1 Execs to run simple do-nothing program (hence, idle ) When nothing needs to be done, system runs idle process Ironically, system does not acknowledge its existence after this
The Init Process Init Process (Process #1) Finishes boot procedure Runs program called init Ancestor of all other processes in the system Never stops running Performs tasks from time to time like slaughtering zombie orphan children
Background Process To run a command in the background, add an ampersand (&) to the end of the command: Without the ampersand, process would run in the foreground
I/O and Background Processes When running in background: Standard input is disconnected Standard output/error STILL connected
REVIEW (16) Job Control and Process Management
Job Control Defined Job control Introduced by Bill Joy when he created C-Shell Can run one process in foreground and many processes in background Can pause and restart processes as needed See status of processes
Job vs. Process Process = single instance of a program running Kernel handles process table Job = all processes necessary to run a command string (E.g., date; who; call job with 3 processes) Has job number (or job ID) and entry in job table Shell handles job table
Running a Background Job To run job in background put ampersand (&) on end Example: who sort uniq c & Will print [job ID] and process ID of last process in command string Shell will notify you when job is done (at next available prompt) If notify set, tells you immediately
States of Jobs Every job is in one of three states: Running in foreground Running in background Paused or Suspended or Stopped NOTE: Stopped does NOT mean Killed or Terminated a stopped job can be resumed
Suspending and Resuming a Foreground Job To suspend a foreground job: CTRL+Z To resume the job: fg command By default, resumes last job you suspended
What Happens When You Logout? When you logout, all suspended jobs are terminated automatically. Shell will warn you once, then let you quit on second try.
Suspending a Shell To pause the shell you are in suspend command One restriction: cannot suspend your login shell (unless you use the f option)
Job Listings jobs command Lists all jobs currently running (or suspended/stopped) current job (+) Default job for fg and bg Most recently suspended or mostly recently moved to background previous job (-) Job directly before current job -l gives long listing (includes process ID)
fg Command fg command Moves a job to the foreground Has three basic forms: fg fg % % The % part can have several variations (shown on next slide)
fg Command Revisited (cont.) % OR %+ Current job %- Previous job %n Job with job ID n %name Job with name at beginning of command %?name Job that has name ANYWHERE in the command string WARNING: The? is NOT used the same way that it usually is in wildcard globbing!
bg Command bg Command Moves a job to the background By default, moves current job to background To specify job number, put %num after it Example: bg %5 Move job 5 to background Can move several jobs to background Example: bg %2 %5 %7
TO CLARIFY When a job is SUSPENDED with CTRL+Z, it is paused (and can be resumed) When a job is in the FOREGROUND or BACKGROUND, it is running When a job is TERMINATED with CTRL+C (or the kill command), it is dead
ps Command Revisited ps command Lists status of processes Two sets of options: UNIX options descended from AT&T Unix BSD options descended from BSD Many modern versions support both sets of options (e.g., Linux) Also GNU options as well
ps By Default ps By default, lists all processes running under your userid from your terminal
ps UNIX Options ps a Lists processes associated with ANY userid AND a terminal ps e Lists ALL processes (including daemons) ps p pid Process with process ID pid ps u userid Processes associated with specified userid
ps BSD Options ps a Lists processes associated with ANY userid AND a terminal ps ax Lists ALL processes (including daemons) ps p pid Process with process ID pid ps U userid Processes associated with specified userid ps u OR ps l Displays different long output versions (more columns)
STAT Column of ps Output STAT = process state The following are for Linux and FreeBSD: R = running T = suspended Z = zombie; terminated, parent not waiting S = interruptible sleep: waiting for event to complete D = uninterruptible sleep: waiting for event to complete (like disk I/O) I = idle (FreeBSD only)
Monitoring System Processes Live To see stats for the processes while they run, use the top command -s time set delay time (default: 2 seconds) -d count sets the number of times to refresh (default: unlimited) WARNING: The book lists different options!
kill Command kill [-signal] pid Used to terminate processes Can use process ID or job ID More generally, sends signal to a process By default, sends TERM (terminate) signal Can be caught by program To kill something immediately, send -9 (or SIGKILL) CANNOT be caught by program May result in data loss (unclosed files), unreleased memory, etc.
Signals Defined Signal Simple form of interprocess communication (IPC) Number sent to a process event occurred Trapping a signal = when the process recognizes the signal and does something about it Some signals cannot be trapped (like SIGKILL)
System Signals There are several different signals: # Name Abbrv. Description 1 SIGHUP HUP Hang-up: sent when you log-out or terminal disconnects 2 SIGINT INT Interrupt: sent when you press CTRL+C 9 SIGKILL KILL Kill: immediate termination; cannot be trapped by a process 15 SIGTERM TERM Terminate: request to terminate; can be trapped by a process 18 SIGCONT CONT Continue: resume suspended process; sent by fg or bg 19 SIGSTOP STOP Stop (suspend): sent when you press CTRL+Z
nice command nice [-n adjustment] command Runs the given command as reduced priority -n set nice number or niceness (0 to 19) 19 lowest priority the most nice you can be If superuser, can use reverse nice number (-1 to -20) -20 highest priority not nice at all
renice command renice niceness p pid Set niceness of existing process with process ID pid Example: renice 19 p 404 Give process 404 the lowest priority possible
Why be nice? You may have long-running processes that you don t want hogging resources use nice (or renice) to reduce priority
Daemons Daemons Process that runs disconnected from a terminal and provide services for the system The init process is a very basic example Most others created during last part of boot sequence by init Others are orphan processes (adopted by init) Often wait silently in background for something to happen then, wakes up, does the thing, and goes back to sleep Similar to Windows services
REVIEW (17) Regular Expressions
Regular Expressions Defined Regular Expressions Used to specify a pattern of characters VERY powerful; used for: Pattern matching Complex substitutions Input verification Used in grep/egrep, sed, vi, less, and many programming languages Also called regex or RE
Matching and Anchors Match when regex corresponds to string of characters All ordinary (non-meta) characters match themselves Should ALWAYS single-quote pattern! Anchors matching beginning/end of something ^ beginning of line $ end of line \< beginning of word \> end of word
Words Word in regular expressions More flexible than in English Self-contained, contiguous sequence of characters consisting of letters, numbers, or underscore (_) Examples: ring Frodo Gandalf81394 1044 Dark_Lord
Matching Single Characters. (Dot) ANY single character [] character class; gives options for a single character Either single characters, range of characters, or both Can be negated with ^ [^Aa] = not A or a
Predefined Character Classes [:lower:] = lowercase letters [a-z] [:upper:] = uppercase letters [A-Z] [:alpha:] = upper and lowercase letters [A-Za-z] [:digit:] = numbers [0-9] [:alnum:] = letters and numbers [A-Za-z0-9] [:punct:] = punctuation characters [:blank:] = space or Tab (whitespace) To use, you have to include the square brackets twice: Example: grep [[:alpha:]]ne
Repetition Operators To repeat something, you use a repetition operator * (Star) zero or more + (Plus) one or more? (Question Mark) zero or one {} specify number of occurrences (create bound) {n} match exactly n times {n, } match n or more times {, m} match m or fewer times (not standard) {n, m} match n to m times May be used with single characters, character classes, or groups Works on whatever is directly before it
Groups and Alternation Group Made using parentheses () Can use ANY of the preceding repetition operators on groups! (vertical bar) allows alternation of patterns E.g., ring stone ring OR stone
Matching a Metacharacter To match a metacharacter, use the escape character \ To match the escape character \\
QUIZ 3
Quiz 3: Question 1 Notions of space: Amount of data in file Number of blocks in filesystem Number of allocation units on disk NOT notion of space: Number of characters in pathname
Quiz 3: Question 2 Determine how much free space is left on hard disks df
Quiz 3: Question 3 Get space taken up by directory and ALL of its contents (i.e., entire directory tree at this point) du
Quiz 3: Question 4 Command to login as root user (super-user): su
Quiz 3: Question 5 Command to execute a single command as the super-user: sudo
Quiz 3: Question 6 Every file is owned by a user and a group.
Quiz 3: Question 7 Owner read, write, execute 111 7 Group, World no permissions 000 0 chmod 700 myfile
Quiz 3: Question 8 Owner, group, world read, write 110 6 chmod 666 myfile
Quiz 3: Question 9 Owner read, write, execute 111 7 Group, world read, execute 101 5 chmod 755 myfile
Quiz 3: Question 10 Owner, group read, write 110 6 World no permissions 000 0 chmod 660 myfile
Quiz 3: Question 11 Owner, group, world read, write, execute 111 7 chmod 777 myfile
Quiz 3: Question 12 Owner read, execute 101 5 Group, world read only 100 4 chmod 544 myfile
Quiz 3: Question 13 Owner, group NO permissions 000 0 World read, execute 101 5 Chmod 005 myfile
Quiz 3: Question 14 Owner, group, world NO permissions 000 0 Chmod 000 myfile
Quiz 3: Question 15 Owner read, write, execute 111 7 Group read, execute 101 5 World NO permissions 000 0 Chmod 750 myfile
Quiz 3: Question 16 Long listing of contents of directory: ls l
Quiz 3: Question 17 (Bonus) Command to show user ID, user name, primary group ID/name, supplementary group IDs/names: id
QUIZ 4
Quiz 4: Question 1 Four things you can do with a variable in Unix (generally): Create Set value Get value Destroy
Quiz 4: Question 2 Environment variable passed down to child processes The child process may or may not be another shell Shell variables NOT passed down to child processes Environment variables are ONLY visible to another shell if that other shell is a CHILD of the current shell So, if one shell defines a variable (environment or otherwise), a sibling or cousin shell on the process tree does NOT see it.
Quiz 4: Question 3 When you type a command (without a full pathname), shell looks for command in a list of directories. This list of directories is stored in the PATH variable
Quiz 4: Question 4 Print value of variable HEISENBERG echo $HEISENBERG REMEMBER: When you want to get the value of a variable, use the dollar sign and name: $HEISENBERG When you want to set the value of a variable, you just use the name itself: HEISENBERG http://www.reactiongifs.com/wp-content/uploads/2013/09/name.gif
Quiz 4: Question 5 echo Kajit has wares, if you have $$$ NEED strong quotes (single quotes), because we want to print the dollar signs ($)
Quiz 4: Question 6 Print ALL environment variables env Print ALL shell variables set
Quiz 4: Questions 7-11 Assume you are using a C-Shell (like csh or tcsh) C-Shells set their variables; also setenv.
Quiz 4: Question 7 Create shell variable named ninjamode set ninjamode The variable does NOT have a value (or rather, the value is just an empty string) Mostly, the variable just EXISTS.
Quiz 4: Question 8 Destroy the shell variable ninjamode unset ninjamode
Quiz 4: Question 9 Create a shell variable named pines with value Dipper, Mabel, & Stan set pines= Dipper, Mabel, & Stan Could use strong (single) or weak (double) quotes here The ampersand (&) and the spaces will still be quoted. http://img4.wikia.nocookie.net/ cb20140821174543/gravityfalls/images/1/16/ Main_characters_of_Gravity_Falls.png
Quiz 4: Question 10 Create an environment variable named MYSTERY_SHACK with value Wendy, Soos, Dipper, Mabel, & Stan using next text and previous variable $pines setenv MYSTERY_SHACK Wendy, Soos, $pines
Quiz 4: Question 11 Destroy the environment variable named MYSTERY_SHACK unsetenv MYSTERY_SHACK
Quiz 4: Questions 12-16 Assume you are using a Bourne shell (sh, bash, ksh) Bourne became an environmental export.
Quiz 4: Question 12 Create a shell variable named GRIMES with value Rick GRIMES=Rick No spaces (or other metacharacters), so quotes are optional here. http://upload.wikimedia.org/wikipedia/en/6/6b/rick_grimes.jpg
Quiz 4: Question 13 Set the value of GRIMES to equal Rick and Lori using new text and the previous value of $GRIMES GRIMES= $GRIMES and Lori Need to use weak quotes (double quotes) because we WANT $ to be interpreted by shell! http://comicicons.files.wordpress.com/2013/04/lori_grimes_sarah_wayne_callies.jpg
Quiz 4: Question 14 Make GRIMES an environment variable export GRIMES GRIMES still has the same value from before ( Rick and Lori )
Quiz 4: Question 15 Change the value of GRIMES to Coral GRIMES=Coral You don t have to use export again, although you could if you wanted to: export GRIMES=Coral http://images6.fanpop.com/image/photos/36700000/carl-grimes-image-carlgrimes-36797407-249-316.jpg
Quiz 4: Question 16 Destroy the variable GRIMES unset GRIMES In Bourne shells, unset is used to destroy both shell AND environment variables
Quiz 4: Question 17 (Bonus) Which specific metacharacters will NOT be escaped by weak quotes (double quotes)? $ (dollar sign) \ (escape character) ` (backquote)