210 likes | 293 Views
Week 3 Lab Agenda. File Name Expansion Review commands More vi More commands to learn. File Name Expansion. Shell metacharacters * – Match 0 to many characters ? – Match exactly one character [abc] – Match one character in a set of characters
E N D
Week 3 Lab Agenda • File Name Expansion • Review commands • More vi • More commands to learn Jan 24, 2005
File Name Expansion Shell metacharacters • * – Match 0 to many characters • ? – Match exactly one character • [abc] – Match one character in a set of characters • [!] – Match all BUT the characters in a set • [a-z] – Match all lower case characters • [a-zA-Z] – Match all alphabetic characters • \ – turn of the magic of the next character Jan 24, 2005
command mode – move in a file • G – move to the last line of the file • 1G – move to the first line of the file • 15G – move to the fifteenth line of the file • m char – mark this location and name this line char • ‘char – move to the beginning of the line named char • ''– return from the last movement Two single quote Jan 24, 2005 source: Ling Zhu
command mode – move in a file • /string – move forward to the first occurrence of string in the file • ?string – move backward to the first occurrence of string in the file • n – repeat last searching • N – repeat last searching in opposite direction Jan 24, 2005 source: Ling Zhu
command mode – move in a screen • ^D – scroll down half screen • ^U – scroll up half screen • ^F – scroll forward one full screen • ^B – scroll backward one full screen • H – move to the top of the screen • M – move to the middle of the screen • L – move to the top of the screen Jan 24, 2005 source: Ling Zhu
command mode – move on a line • 0 – move to the beginning of the line • $ – move to the end of the line • fm – move forward to the first occurrence of m on the line • 3ff – move forward to the third occurrence of f on the line • Fn – move backward to the first occurrence of m on the line • 3F4 – move backward to the third occurrence of 4 on the line Jan 24, 2005 source: Ling Zhu
command mode – move between words • w – move to the beginning of the next word • e – move to the end of the next word • b – Move back to the beginning to the previous word • W – move to the beginning of the next WORD • E – move to the end of the next WORD • B – Move back to the beginning to the previous WORD delimited by any non-alphanumeric character delimited by any blank space Jan 24, 2005 source: Ling Zhu
command mode – more movement • { – move backward to the beginning of a paragraph • } – move forward to the end of a paragraph • ( – move backward to the beginning of a sentence • ) – move forward to the end of a sentence Jan 24, 2005 source: Ling Zhu
Can you answer? What would be the result of issuing the following sequences of vi commands? • <ESC>3k3Wd$ • <ESC>k3laalt • <ESC>2kCmkdir<ESC>kill Jan 24, 2005 source: Ling Zhu
More about vi – command mode • J – join two lines • ZZ – exit and save any change • . – repeat last change Jan 24, 2005 source: Ling Zhu
vi command mode – cut and paste • dw – delete to the beginning of the next word • d$ – delete to the end of the line • d) – delete to the beginning of the next sentence • dte – delete till the next e • dd – delete the current line Latest deleted text is saved in a buffer. How to put it? • p – put the content before the cursor or line • P – put the content after the cursor or line Jan 24, 2005 source: Ling Zhu
Advanced vi – copy and paste • y10G – copy from here to line 10 • y$ – copy to the end of the line • yL – copy from here to the last line of the screen • y'a – copy from here till the marked line a • yy – copy the whole line Latest copied text is saved in a buffer. How to put it? • p – put the content before the cursor or line • P – put the content after the cursor or line Jan 24, 2005 source: Ling Zhu
Advanced vi – named buffer • “adw – delete to the beginning of the next word and saved to the buffer named a • “bd$ – delete to the end of the line and saved to the buffer named b • “cyL – copy from here to the last line of the screen and saved to the buffer named c • “dyy – copy the whole line to the buffer named d How to put the latest text in buffer? • “ap – put buffer a content before the cursor or line • “bP – put buffer b content after the cursor or line Jan 24, 2005 source: Ling Zhu
Advanced vi – command mode • ^G – display the status of the current file • ^L – refresh screen • ^Z – suspend this job and return to the Unix command line and fg come back to the suspend job • ~ – convert case Jan 24, 2005 source: Ling Zhu
Advanced vi – last line mode • :e– edit a file • :!– execute commands without exit vi Jan 24, 2005 source: Ling Zhu
Symbols for Special Directories . current working directory .. parent directory ../.. grandparent directory your home directory ~ $HOME your home directory Jan 24, 2005 source: Ling Zhu
Review last week commands • cp policydestination • What if destination is a file that doesn’t exist? • What if destination is a file that exists? • What if destination is a directory? • What if there is a policy file under destination? • mv policydestination • Can you answer the last four questions? Jan 24, 2005 source: Ling Zhu
Review last week commands • What are the siz commands to view a file? • Why less can do more work then more does? Jan 24, 2005 source: Ling Zhu
Review last week commands • Which is the command to remove a file? • Which is the command to rename a file? • What is the difference between rm -r and rmdir ? Jan 24, 2005 source: Ling Zhu
More Details of Commands Learned • cat • Display the content of a file or multiple files - eg: cat file1 display the content of file1 - eg: cat file2 file3 file4 display the content of file2, file3 and file4 • Combine with > to copy a file • Combine with > to create a new file use ctrl+D to finish • Combine with >> to append to a file Jan 24, 2005 source: Ling Zhu
More Details of Commands Learned • mkdir -p Make pass directories as needed. • ls –d List directory entries instead of contents • rm –i Prompt before any removal • rm –ri When delete directory with contents, prompt before any removal Jan 24, 2005 source: Ling Zhu