290 likes | 733 Vues
CIS52 Week 3 Agenda User Communication System V Manual Sorting Searching File Compression Miscellaneous Utilities User Communication write talk mesg mail biff finger write sends a message to another logged on user syntax: write destination-user [terminal]
E N D
CIS52 Week 3
Agenda • User Communication • System V Manual • Sorting • Searching • File Compression • Miscellaneous Utilities
User Communication • write • talk • mesg • mail • biff • finger
write • sends a message to another logged on user • syntax: write destination-user [terminal] one or more lines of text ^d • example: write n01 Having a bad Unix day? ^d
mesg • allows write and talk to send messages to you (or not) • example: mesg n mesg y
mail • Modeled after typical postal system • Unix post office has file for each user • /usr/spool/mail/n01 • each user also has a personnel mailbox called mbox. (created in users home directory) • when you read mail, it is moved to your postbox.
mail • Mail consists of • heading and body • heading • to • subject • cc • bcc • body is your message.
mail • Two modes: compose and command • type mail at shell prompt to enter command mode. • type mail user-id to enter compose mode end compose mode with ^d (type a period in linux) ~ allows you to shell out to another command • ~v • ~r myfile
Mail command options • q leave mail • r reply to originator • R reply to everyone on distribution list • d delete current message • ! Shell out (ie, !date) • ? Help • h display list of message headers
biff • Toggle switch to alert you when mail has been sent • biff y • biff n • BSD utility .. Not on many systems
talk • two way conversation with split screen visable for both • example: talk n01 • lines of message • ^d (on some systems, the del key)
finger • displays info about a user • login id, name, tty, idle time, log in status • example: finger n01 • Will also display contents of a .plan file (if in the targets home directory
Man Pages • 8 Sections • At least 3 parts to each page • name and purpose • synopsis (command usage, arguments) • description • Optional • diagnostics, bugs, examples
Man Pages • Development of the man pages • nroff utility for low resolution devices • terminals • dot matrix printers • line printers • troff utility for high resolution devices • lasers and phototypsetters
System V Manual Sections • 1. Commands and application programs • 2. System Calls • 3. Library Functions • (BSD .. Special files, drivers) • 4. File Formats • (BSD .. File formats, sys admin)
System V Manual Sections • 5. Miscellaneous • 6. Games • 7. Special Files • (BSD .. Miscellaneous) • 8. System Maintenance
Sorting • Options • f upper and lower case considered the same • r reverse order (ie, z to a) • u duplicate entries are eliminated from output • k defines the field to start the sort comparisons. Count starts with 1 (replace k with a number) • b ignores blanks
What is a ‘field’ • Contains ascii data • delimited by ‘whitespace’ • whitespace is: • tab • blank • carriage return • example • the day the earth stood still
Sorting • Examples • sort myfile • sort -r myfile • sort file1 file2 • sort file1 file2 > file3 • sort +1 myfile • (skip a field, then start comparisons)
Sorting • sort +1 -2 myfile • skip a field (start sort in field number 2) • end sort at end of field 2 • sort -b +2.1 -3 • -b ignore blanks • +2 skips first two fields • .1 skip 1 character in next field • 3 ends sort key at end of field 3
Searching with grep • searches standard in for a pattern • sends all lines with that pattern to std out • options • -v ignore lines which do NOT have pattern • -i ignore case • -c count lines • -n print line numbers • -l print file names only
grep • Examples • grep aardvark animalfile • grep -v aardvark myfile • grep -vi minnie myfile • who | grep minnie • grep * data • grep -l ‘[D,d]ata’ *
File Compression • compress • examines file, searches for repeated patterns • recodes file and renames with .Z • uncompress • restores compressed file to original form • removes .Z • zcat • sends content of compressed file to std out.
compression • Compress -v myfile • myfile.Z (v prints name of file % % compression) • cat myfile.Z • zcat myfile.Z • uncompress myfile.Z
Miscellaneous Utilities • File displays type of file • file file1.Z • diff displays difference between two files • diff myfile yourfile • uniq displays unique lines • assumes file is sorted • uniq myfile
tr (translate) • tr is a filter and does not allow filename to be entered as an argument • tr must get its data from std in • either from <file or from a pipe • tr a A <myfile • who | tr a A • who | tr abc ABC • who | tr ‘[a-z] [A-Z]’
Feedback What do the following commands do? • mail minnie < temp • who | mail minnie • compress myfile | mail minnie • mesg n • sort -r myfile • sort +3 myfile
Feedback • grep -v clinton • grep abc* temp • grep unix lab[1-6] • tr a B myfile • who | ls • who > wc -l • woof y