120 likes | 237 Views
This document summarizes the key concepts discussed in the CSC 4630 meeting on January 29, 2007, focusing on resolving issues related to the UNIX shell. It explores essential properties of shell programming, including input/output redirection, regular expressions, and user-defined commands. Participants engaged in comparative exercises using commands like `ls`, `echo`, and `who`, highlighting command interpretation nuances and command grouping. This concise overview serves as a guide to understanding shell functionalities and practices in UNIX environments.
E N D
CSC 4630 Meeting 4 January 29, 2007
Mysteries • What do we need to resolve? • What issues did the Moby Dick homework raise?
What About Shells • What do you know about the UNIX shell?
The Shell • A program, specifically a command interpreter • Special properties • Limited understand of regular expressions to denote sets of files • I/O redirection • User defined commands
Shell: Regular Expressions • * matches any string, including the empty string. Equivalent to .* for grep • [s] matches any single element of the set s. The set can include ASCII ranges, for example m-t designates the set {m n o p q r s t}
Shell: I/O Redirection • Four symbols < Take input from > Send output to, overwriting what was previously there >> Send output to, appending new information to the end of the file | Use output from first command as input to second command
Shell: Command Interpreter • Single word commands • Names a file for execution, e.g. who means run the command file /bin/who • Command termination • newline • semi-colon ; • ampersand &
Shell: Command Interpreter (2) • Command grouping: compare • date; who (a sequence of commands on one line with • date; who | wc (Which of ; and | has higher precedence?) with • (date; who) | wc with • date; (who | wc)
Shell: Command Interpreter (3) • The ampersand means run the command in the background. • Example: (sleep 5 ; date) & date
Shell: Exercises • Compare ls junk and echo junk, where junk is the name of a file in the current directory. • Compare ls / and echo / • Compare ls and echo (given as commands with no arguments) • Compare ls * and echo * • Compare ls ‘*’ and echo ‘*’
Shell: Exercises (2) • Explain the results of ls > ls.out • Explain the results of wc temp > temp • Explain the results of whom (given as a command without an argument) • Compare who | sort and who > sort • Compare • cat file | pr with • pr < file with • pr file
Shell: Exercises (3) • Explain the results of ls .*