In-class Examples List
CS 279 - Introduction to Linux
Section 10 - CRN 43313 - MW 9:00-10:20am
Fall 2022
Last modified: Wednesday, December 6, 2022
Important Notes:
- This is merely a selection of files and examples, most of which were
mentioned or used in the class (lectures and labs). It is not a
comprehensive
list, nor are all lectures and labs included. Formatting is generally
minimal.
- Week 15 - Lab, December 8, 2022 - opportunity to work on Homework 10,
ask questions/get help with Homework 10
(and parts improving from Homeworks 8, 9)
- Week 15, Lecture 2, December 7, 2022 - Final Exam review
- Week 15, Lecture 1, December 5, 2022 -
including a few items related to UNIX/Linux
system administration, such as
sudo
- Week 14, Lab, December 1, 2022 - review clicker questions
followed by a lab exercise
- Week 14, Lecture 2, November 30, 2022 -
includes intros to more fun utilities, and to
at
, batch
, and crontab
- Week 14, Lecture 1, November 28, 2022 -
how can one (kind of!) "return" a value from
a Bash function; Bash
case
statement;
some UNIX/Linux commands to find out "about the system"
(uname
, uptime
, who
,
top
)
- Week 13, Lab, November 17, 2022 - review clicker questions
followed by a lab exercise
- Week 13, Lecture 2, November 16, 2022 - a bit more
about hard links and symbolic/soft links, and started intro to
Bash functions
-
Week 13 Lecture 2 projected notes
-
https://www.shellscript.sh/functions.html - current version is rather
ads-laden, but I did find this
old-but-still-available site to be a helpful reference for *Bourne shell*
(a major Bash predecessor!) functions
- moo-funct-play.sh
- includes two Bash functions and calls to those functions
- just-moo-functs.sh
- this version contains JUST the two Bash functions
moo5
and custom_moo
- use-moo-functs.sh
- this script uses the
source
command to
get access to the functions in just-moo-functions.sh
,
and then calls those functions
- scope1.sh
- plays a bit with function "parameters" and shell-script
command-line arguments, to demonstrate Bash's scope rules
- Week 13, Lecture 1, November 14, 2022 -
more options for searching through history, how files are
stored in UNIX/Linux, intro to hard links and symbolic/soft
links
- Week 12, Lab, November 10, 2022 - review clicker questions
followed by a lab exercise
- Week 12 - Lecture 2, November 9, 2022 - Exam 2
- Week 12, Lecture 1, November 7, 2022 - intro to the
sed
command
- Week 11 - Lab, November 3, 2022 - no lab, instructor attending
CCSC-NW 2022 - work on Homework 7, study for Exam 2
- Week 11, Lecture 2, November 2, 2022 - review for Exam 2
- Week 11, Lecture 1, October 31, 2022 - includes
intro to the commands
find
, tar
,
gzip
, gunzip
, head
,
and tail
- Week 10, Lab, October 27, 2022 - review clicker question
followed by a lab exercise
- Week 10, Lecture 2, October 26, 2022 - continued
intro to Bash arrays, and also demo'd the
BASH_REMATCH
array
-
Week 10 Lecture 2 projected notes
- Source for today's array material:
a Linux Journal article:
"Bash Arrays" - Mitch Frazier - June 2008
-
linux-journal-ex - completing the adaptation
of one of the examples from the above Linux Journal
article
-
quoted-play - another example adapted from
the above Linux Journal article, comparing
quoted array expansion using [*] vs. [@]
-
rematch-play - trying out the
BASH_REMATCH
array for a small RE
-
clicker-rematch.sh - demonstrating the
BASH_REMATCH
array contents for
one of today's clicker questions
-
grab-if-conds - using the
BASH_REMATCH
array to try and
grab the conditions used in if statements
within an argument file
- Week 10, Lecture 1, October 24, 2022 - includes
demos of commands
sort
and tee
,
and started intro to Bash arrays
-
Week 10 Lecture 1 projected notes
- Source for today's array material:
a Linux Journal article:
"Bash Arrays" - Mitch Frazier - June 2008
-
array-play - a
bash
demonstrating some Bash array
features
-
linux-journal-ex - adapting the first
part of one of the examples from the above Linux Journal
article
- Week 9, Lab, October 20, 2022 - review clicker question
followed by a lab exercise
- Week 9, Lecture 2, October 19, 2022 -
a bit more about EREs (Extended Regular Expressions);
/dev/tty
and /dev/null
;
and a few more classic commands:which
,
cmp
and diff
, more on wc
- Week 9, Lecture 1, October 17, 2022 - includes
one of the Bash-shell possibilities for reading
the lines from a file, the
=~
operator
for being able to write tests comparing a string to a
BRE, some more BRE options, and a few Extended Regular Expression
(ERE) options
-
Week 9 Lecture 1 projected notes
-
bracket-all - a
bash
shell script showing how you
can use redirected standard input along with a
while
loop to read all of the lines
from a file
-
regex-play - a
bash
shell script demoing the
use of the operator =~
to write
a test expression comparing a string to a BRE
-
play.txt - a rather strange text file we
used with the above shell scripts and some of
today's interactive bash shell example commands
- Week 8, Lab, October 13, 2022 - review clicker question
followed by a lab exercise
- Week 8, Lecture 2, October 12, 2022 - continued
our discussion of the
grep
command, and started our discussion of UNIX/Linux
Basic Regular Expressions (BREs)
-
Week 8 Lecture 2 projected notes
- animals.txt,
clicker2.txt - two
weird little files we used in today's in-class demos
- for
grep
basics and BREs:
- LDP Bash Beginner's Guide - Chapter 4 - Regular Expressions, at
https://tldp.org/LDP/Bash-Beginners-Guide/html/chap_04.html,
(and its Table 4.1, Regular Expression Operators, but it does NOT include
bracket expressions; they're discussed later, I'm not sure why...?):
https://tldp.org/LDP/Bash-Beginners-Guide/html/sect_04_01.html#table_04_01
- Section II, Chapter 19 - "Regular expressions", Sections 19.1, 19.2,
in 2021 partial-rewrite version
of course text, has SOME of the BRE material;
http://linux-training.be/linuxtraining_20211003.pdf
- (I'm not finding a section I like for BREs in the GNU Bash Reference
Manual - there's some of it in with conditional expressions in
section 3.2.5.2 Conditional Constructs, but not as "separated" as I'd like.)
- Week 8, Lecture 1, October 10, 2022 - includes
a few more examples of UNIX/Linux signals,
more options for file globbing patterns,
and started our discussion of the
grep
command
- Week 7, Lab, October 6, 2022 - review clicker question
followed by a lab exercise
- Week 7, Lecture 2, October 5, 2022 - includes more discussion
of processes and jobs; also includes how to see the
exit status of the last completed command, a bit more about
standard files and redirection, some discussion of
bash initialization files, updating one's
PATH
environment variable, and intro to the alias
command
Week 7, Lecture 1, October 3, 2022 - includes more discussion
of processes and jobs; also includes an intro to
pipes, to the source
command,
and to the environment variable
PS1
for specifying one's shell prompt,
as well as an example of a while
loop and a
first mention of the grep
command
Week 6, Lab, September 29, 2022 - review clicker questions
followed by a lab exercise
Week 6 - Lecture 2, September 28, 2022 - Exam 1
Week 6, Lecture 1, September 26, 2022 - more on
environment variables; started intro to processes
and jobs
Week 5, Lab, September 22, 2022 - review clicker questions
followed by a lab exercise
Week 5 Lecture 2, September 21, 2022 - review for Exam 1
Week 5, Lecture 1, September 19, 2022 - includes more discussion
on test expressions; intro to environment variables
-
Week 5 Lecture 1 projected notes
-
ext-bracket-play - a
bash
shell script trying out some
tests within (( ... ))
and
[[ ... ]]
brackets
-
quick-loop-ex - a
bash
shell script
demonstrating the difference between a list-style
for
loop using #@
versus using "#@"
when command-line
arguments with blanks are involved
-
harmless-to-call - a
bash
shell script
to help demo how changing a copied environment variable
in a script does not change that variable in the
spawning shell (ls
will work in calling
shell after this script is completed)
Week 4, Lab, September 15, 2022 - review clicker questions
followed by a lab exercise
Week 4, Lecture 2, September 14, 2022 - topics discussed
included why we will prefer $@
over
$*
in CS 279, intro to bash
shell's two styles of for
loops, and more
intro to bash
shell
if
statements
-
Week 4 Lecture 2 projected notes
- Here are some references for some of the testing
options you
can use in
if
statements:
-
list-for-demo - a
bash
shell script demonstrating
several examples of "list-style"
for
loops
-
classic-for-demo - a little
bash
shell script demonstrating
a "classic"-style for
loop
-
more-if-play - a
bash
shell script demoing more
examples of if
statements
-
try-this - a small
bash
shell script seeing if one
shell script can call another in the current
directory within backquotes to generate a list
to loop through (calls classic-for-demo
above)
Week 4, Lecture 1, September 12, 2022 - bash
interactive input, command-line argument variables, grabbing
parts of a file path, exiting a script early, and start of intro
to the bash
shell's if
statement
-
Week 4 Lecture 1 projected notes
-
fruit-clicker - a little
bash
shell script demoing the
difference in how shell variables are treated
when inside double quotes versus single quotes
-
simple-read - a little
bash
shell script with an example of using
the read
command for interactive shell
input
-
see-args - a little
bash
shell script demonstrating how to grab
command-line arguments
-
path-pieces - a little
bash
shell script demoing using
commands basename
and dirname
to grab the base file name and the directory from
a given file pathname
-
if-play - a little
bash
shell script demoing two
examples of if
statements
Week 3, Lab, September 8, 2022 - more discussion of
shell local variables
followed by a lab exercise
Week 3, Lecture 2, September 7, 2022 - intro to file
permissions, ls
options l
and
d
, intro to the chmod
command,
intro to local shell variables
Week 3, Lecture 1, September 5, 2022 - NO CLASS, Humboldt Labor Day Holiday
Week 2, Lab, September 1, 2022 - review clicker questions
followed by a lab exercise
Week 2, Lecture 2, August 31, 2022 - more on the
UNIX/Linux filesystem, including some more
file-oriented
commands, including ls -a
,
cp
, diff
, mv
,
rm
, and rmdir
; also
started discussion of file globbing using the
wildcard character *
Week 2, Lecture 1, August 29, 2022 - more on the
UNIX/Linux filesystem, and some more file-oriented
commands; includes discussion about such filesystems,
pathnames (both relative and absolute), convenient
provided nicknames for directories, filename
completion, output file redirection, and more
Week 1, Lab, August 25, 2022 - using ssh
to
connect to nrs-projects.humboldt.edu
,
starting our discussion of UNIX/Linux filesystem and
some file-related commands, along with a lab exercise
Week 1, Lecture 2, August 24, 2022 - what is a command shell,
some common UNIX/Linux shells, basic UNIX/Linux command
syntax, what is a shell script, our first bash
shell script
Week 1, Lecture 1, August 22, 2022 - intro to course
Back to Course Home Page