1 / 29

CIS52

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]

albert
Télécharger la présentation

CIS52

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CIS52 Week 3

  2. Agenda • User Communication • System V Manual • Sorting • Searching • File Compression • Miscellaneous Utilities

  3. User Communication • write • talk • mesg • mail • biff • finger

  4. 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

  5. mesg • allows write and talk to send messages to you (or not) • example: mesg n mesg y

  6. 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.

  7. mail • Mail consists of • heading and body • heading • to • subject • cc • bcc • body is your message.

  8. 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

  9. 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

  10. biff • Toggle switch to alert you when mail has been sent • biff y • biff n • BSD utility .. Not on many systems

  11. talk • two way conversation with split screen visable for both • example: talk n01 • lines of message • ^d (on some systems, the del key)

  12. 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

  13. Man Pages • 8 Sections • At least 3 parts to each page • name and purpose • synopsis (command usage, arguments) • description • Optional • diagnostics, bugs, examples

  14. 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

  15. 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)

  16. System V Manual Sections • 5. Miscellaneous • 6. Games • 7. Special Files • (BSD .. Miscellaneous) • 8. System Maintenance

  17. 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

  18. What is a ‘field’ • Contains ascii data • delimited by ‘whitespace’ • whitespace is: • tab • blank • carriage return • example • the day the earth stood still

  19. Example

  20. Sorting • Examples • sort myfile • sort -r myfile • sort file1 file2 • sort file1 file2 > file3 • sort +1 myfile • (skip a field, then start comparisons)

  21. 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

  22. 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

  23. grep • Examples • grep aardvark animalfile • grep -v aardvark myfile • grep -vi minnie myfile • who | grep minnie • grep * data • grep -l ‘[D,d]ata’ *

  24. 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.

  25. compression • Compress -v myfile • myfile.Z (v prints name of file % % compression) • cat myfile.Z • zcat myfile.Z • uncompress myfile.Z

  26. 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

  27. 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]’

  28. 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

  29. Feedback • grep -v clinton • grep abc* temp • grep unix lab[1-6] • tr a B myfile • who | ls • who > wc -l • woof y

More Related