84aa246169f111ae0b1d77b3dc26cbc4.ppt
- Количество слайдов: 34
Unix File System z. Stores Files y. Text, Programs, Images, etc. z. Made up of Many Files y. User, Unix System, Unix Commands 1
Unix File System Top most directory in Unix Home Directory containing all home directories 2
Unix File System z Home Directory y. Personal Directory to store files y. Usually the Directory Name = login ID y. Current Directory after successful login Home directories for: rdefe, jsmith and djones 3
Unix File System z. What Can You Do? y. Create New Files & Directories y. Organize Files y. Locate Files Based on a Directory Structure y. Change to a New Directory 4
Unix File System z. File & Directory Naming Guidelines y. Don’t Use Meta Characters x/ “ ` * ; ? { } ( ) [ ] ~ ! $ < > | & # y. Do Use xa-z A-Z x 0 -9 x. _ - y. Remember Unix is Case Sensitive! 5
Unix File System z. File & Directory Name Examples yfeb 1998, 178987, my_data, my. data. new ymbox, Mbox, mbo. X, MBOX, m. Box yprog 1. . 2 y. profile 6
Unix Commands zls y. List Files & Directories $ ls 198 A aa. bb. cc. dd bin datefile etc mail mbox. old unix $ 7
Unix Commands zls -p y-p Show Directories $ ls -p 198 A aa. bb. cc. dd bin/ datefile etc/ mail/ mbox. old unix/ $ 8
Unix Commands zls [directory 1] [directory 2]. . . y. List the contents of a directory $ ls -p 198 A aa. bb. cc. dd bin/ datefile etc/ mail/ mbox. old unix/ $ $ ls unix awk. data awk. prg bgraph cpy homework 2 homework 3 unix 2 test $ 9
Unix Commands zls -s y-s Show File Size in Blocks y. Block Sizes $ ls -s x 512 bytes x 1024 bytes x 2048 bytes total 19 1 198 1 A 1 aa. bb. cc. dd 1 bin 1 datefile 1 etc 1 mail 2 mbox 1 unix 10
Unix Commands zls -l y-l Long Listing $ ls -l total 19 -rw-r--r-drwxr-xr-x -rw------drwxr-xr-x $ 1 1 2 3 2 2 1 2 rdefe rdefe unix unix 53 62 96 80 64 32 984 144 Sep Sep Aug 12 12 4 29 29 2 12 29 21: 46 21: 47 20: 58 20: 54 1992 21: 44 20: 54 198 A bin db etc mail mbox unix 11
Unix Commands zls -a y-a List All Files Include Files That Begin with a ‘. ’ Files that begin with a ‘. ’ are usually configuration files $ ls -a . . profile. sh_history 198 A bin datefile db etc mbox unix $ 12
Unix Commands zls -r y-r Reverse Sort zls -R y-R List Contents of Subdirectories • List files in each subdirectory. • Subdirectories with Subdirectories will also be listed…and so on. . . $ ls -r unix mbox mail etc db datefile bin A 198 $ 13
Unix Commands zls -l -t or ls -lt y-t Sort On Modification Time $ ls -lt total 19 -rw-r--r--rw------drwxr-xr-x drwxr-xr-x $ 1 1 1 2 2 2 3 2 rdefe rdefe unix unix 62 53 984 96 64 144 80 32 Sep Sep Aug Aug Sep 12 12 12 4 29 29 29 2 21: 47 21: 46 21: 44 20: 58 20: 54 1992 A 198 mbox bin etc unix db mail 14
Unix Commands or zls -l -t -r ls -ltr y-tr Reverse Sort On Modification Time $ ls -ltr total 19 drwxr-xr-x drwxr-xr-x -rw-------rw-r--r-$ 2 3 2 2 2 1 1 1 rdefe rdefe unix unix 32 80 144 64 96 984 53 62 Sep Aug Aug Sep Sep 2 29 29 29 4 12 12 12 1992 20: 54 20: 58 21: 44 21: 46 21: 47 mail db unix etc bin mbox 198 A 15
Unix Commands zls -[ltr. Ra] [Filename 1] [Filename 2] … y. Unix. Command Options Arguments $ ls -lt unix $ 16
Unix Commands zcat [Filename 1] [Filename 2] … y. Concatenate Files y. Display Files to the Screen y. Ctrl-s Pause Screen y. Ctrl-q Unpause Screen $ cat sample. file This is a sample file that i'll use to demo how the pr command is used. The pr command is useful in formatting various types of text files. $ 17
Unix Commands zmore [Filename 1] [Filename 2] … y. Display Files to the screen one page at a time $ more largefile This is a sample file that i'll use to demo how the pr command is used. The pr command is useful in formatting various types of text files. --More--(16%) z Spacebar (next page) z b (previous page) z Enter Key (next line) z z q (Quit & return to unix) /string (search for string) : n (next file) : p (previous file) 18
Unix Commands z lpr [Filename 1] [Filename 2] … y. Send Files to a Unix Printer y. No Formatting (page numbers, etc. ) $ lpr prog 1 mbox $ $ pr sample. file Ideal solution would be to combine the lpr & pr to achieve formatted printed output 98 -05 -22 23: 07 sample. file Page 1 This is a sample file that i'll use to demo how the pr command is used. . 19
Unix Redirection z. Redirecting Input y. A Command Requiring Input Can Receive it’s Input From a File $ mail rdefe < mesg $ 20
Unix Redirection z. Redirecting Input $ mail rdefe < mesg $ Command that requires input Command < File used to provide input (instead of typing it!) 21
Redirection Examples 1 $ pr data > data. pr $ lpr data. pr 2 $ cal 3 1993 > year Using arguments with redirection 3 $ ls -l data > stuff Using arguments & options with redirection Is the same as $ pr data | lpr 22
Redirection Examples 4 $ pr data > lpr 5 $ cat text let > mesg 6 $ pr f 1 f 2 > f 1 1 2 Create the file f 1 Erases f 1 if it already exists pr f 1 and f 2, redirect to f 1 23
Unix Commands zrm [Filename 1] [Filename 2] … yremove files * is a Meta Char that matches anything $ rm prog 1 mbox $ $ rm p* $ z Caution $ rm * $ y. Unix Assumes You Know What Your Doing y. Be Sure You Know What Your Deleting y. No Undelete! 24
Unix Commands zvi [Filename] y. Full Screen, Visual Editor y. Changes Displayed As They Are Made y. Edits A Copy of the File y. Changes Must Be Saved $ vi mesg y emacs http: //www. gnu. org/software/emacs. html 25
Unix Commands Vi Modes z Command Mode y. Start in command mode y. Every Key Performs an Editing Command z Insert Mode y. Perform Text Entry/Input Insert Mode Command Mode Insert Mode ESC Key 26
Sample vi Edit Session $ vi mesg z z z Welcome to UNIX Wnewtextelcome to UNIX This is an example of a text file in vi This is an example of ~ a text file in vi ~ ~ : wq $ Start in Command Mode Press a key for Append After Cursor Command Enter text (Input Mode) Press ESC key (Command Mode) Press : wq followed by Enter key to Save & Exit 27
Cursor Positioning z. Moving the Cursor in Command Mode k h Key l j w b Cntrl-d Cntrl-u Enter G 5 G Command Forward One Word Backward One Word Scroll Down Scroll Up Down One Line Go To Last Line Go To Line 5 28
Text Input Mode vi Text Input Mode Commands Wnewtextelcome to UNIX a Append After Cursor Welcome to UNIXnewtext This is an example of A Append at End of Line a text file in vi newtext. Welcome ~ This is an example ofto UNIX i Insert Before Cursor ~ a text file in vi is an example of ~ Thisnewtext. Welcome to UNIX I Insert at Beginning of ~ a text file in vi Line ~ This is an example of newtext ~ a text file in vi O Open New Line Above Cursor Welcome to UNIX ~ o Open New Line Below Cursor ~ This is an example of R Replace Text (typeover) a text file in vi ~ r Replace One Char ~ 29
Deleting Text Welcome to UNIX This is an example of a text file in vi ~ This is an example of ~ a text file in vi ~ ~ x Delete One Char X Delete Char Before Cursor dd Delete One Line z Proceed Any Command with a Number to multiply effect y 4 x Delete 4 chars y 5 dd Delete 5 lines y 3 dw Delete 3 words 30
Undo Changes Welcome to UIX Welcome to UNIX This is an example of a text file in vi ~ This is an example of WELcome ~ a text file in vi to UIX 123 ~ Welcome to UNIX ~ This is an example of a text file in vi ~ This is an example of ~ a text file in vi ~ ~ x Delete One Char u Undo Last Change U Undo All Changes on Line 31
Saving Your Changes z. Command Mode y. ZZ y: wq y: w data y: q! Save & Exit vi Save to a file data Quit Without Saving Changes z. Vi reference Card y http: //vh 224401. truman. edu/~dbindner/mirror/vi-ref. pdf 32
Other Goodies. . . z /string Forward Search for `string` z ? string Backward Search for `string` yn y. N z Ctrl-G z. J Repeat Search in reverse direction Display Current Location in File Join two lines together z http: //www. thomer. com/thomer/vi/vi. html 33
That’s All. . . 34