Tuesday, September 7 CS 375 UNIX System Programming - Lecture 4 1
Lecture 4
Log into Linux Reminder: Homework 1 due today, 4:30pm Homework 2 out, due next Tuesday Project 1 out, due next Thursday Questions?
Lecture 4 Log into Linux Reminder: Homework 1 due today, 4:30pm - - PowerPoint PPT Presentation
Lecture 4 Log into Linux Reminder: Homework 1 due today, 4:30pm Homework 2 out, due next Tuesday Project 1 out, due next Thursday Questions? Tuesday, September 7 CS 375 UNIX System Programming - Lecture 4 1 Outline More
Tuesday, September 7 CS 375 UNIX System Programming - Lecture 4 1
Log into Linux Reminder: Homework 1 due today, 4:30pm Homework 2 out, due next Tuesday Project 1 out, due next Thursday Questions?
Tuesday, September 7 CS 375 UNIX System Programming - Lecture 4 2
More BASH programming Command Substitution Arithmetic Substitution Additional Useful Commands Grouping Exercises
Tuesday, September 7 CS 375 UNIX System Programming - Lecture 4 3
Command substitution allows the standard
Tuesday, September 7 CS 375 UNIX System Programming - Lecture 4 4
Arithmetic evaluation uses either let expr or
Tuesday, September 7 CS 375 UNIX System Programming - Lecture 4 5
HERE documents are a special form of input
Tuesday, September 7 CS 375 UNIX System Programming - Lecture 4 6
Functions only have local scope by default, but
You can create aliases for commands too:
Tuesday, September 7 CS 375 UNIX System Programming - Lecture 4 7
Bash shells can be
interactive or non-interactive a login or non-login shell.
A login shell reads and executes commands
A non-login interactive shell reads commands
Tuesday, September 7 CS 375 UNIX System Programming - Lecture 4 8
find will locate files and directories that satisfy
Syntax: find <dir> <matching criteria> <actions> Lots of matching criteria, e.g. -mtime n, -type c,
Some built-in actions, e.g. -print, -ls. General
Tuesday, September 7 CS 375 UNIX System Programming - Lecture 4 9
find examples:
Tuesday, September 7 CS 375 UNIX System Programming - Lecture 4 10
grep search for files containing regular
xargs takes filenames from standard input and
expr is an all-purpose expression evaluator
Tuesday, September 7 CS 375 UNIX System Programming - Lecture 4 11
exec replaces the current process with a new
bc is an arbitrary precision calculator.
Tuesday, September 7 CS 375 UNIX System Programming - Lecture 4 12
export makes a shell variable available in
read will read a line of input from standard
printf can give fancier output than echo.
Tuesday, September 7 CS 375 UNIX System Programming - Lecture 4 13
Use the following code to read lines of input
Input (and output) is redirected for all
Tuesday, September 7 CS 375 UNIX System Programming - Lecture 4 14
You can also redirect input and/or output by
Use space between the command group and
Tuesday, September 7 CS 375 UNIX System Programming - Lecture 4 15
You can use ( ) for grouping too. With ( ), the
Tuesday, September 7 CS 375 UNIX System Programming - Lecture 4 16
Write a shell script named lastfirst that takes a
Hint: Try “man -k reverse” to find relevant utilities. Write appropriate error messages if an incorrect number of
Exit with appropriate status. Read from standard input if no arguments are given.
Tuesday, September 7 CS 375 UNIX System Programming - Lecture 4 17
Write a shell script named sortusers1 that
Write sortusers2 that displays every other
Write a shell script named revargs that