11 Jan 24, 2005Jan 24, 2005
Week 3 Lab AgendaWeek 3 Lab Agenda
File Name Expansion File Name Expansion Review commandsReview commands More viMore vi More commands to learnMore commands to learn
22 Jan 24, 2005Jan 24, 2005
Shell metacharactersShell metacharacters * * – Match 0 to many characters– Match 0 to many characters
? ? – Match exactly one character– Match exactly one character
[abc] [abc] – Match one character in a – Match one character in a setset of of characters characters
[!] [!] – Match all – Match all BUTBUT the characters in a set the characters in a set
[a-z] [a-z] – Match all lower case characters– Match all lower case characters
[a-zA-Z] [a-zA-Z] – Match all alphabetic characters– Match all alphabetic characters
\ \ – turn of the magic of the next character– turn of the magic of the next character
File Name ExpansionFile Name Expansion
33 Jan 24, 2005Jan 24, 2005
GG – move to the last line of the file – move to the last line of the file
1G1G – move to the first line of the file – move to the first line of the file
15G15G – move to the fifteenth line of the file – move to the fifteenth line of the file
m charm char – mark this location and name this line char – mark this location and name this line char
‘ ‘charchar – move to the beginning of the line named – move to the beginning of the line named charchar
'''' – return from the last movement– return from the last movement
command mode – move in a filecommand mode – move in a file
source: Ling Zhu
Two single quote
44 Jan 24, 2005Jan 24, 2005
/string/string – move forward to the first occurrence – move forward to the first occurrence of string in the file of string in the file
?string?string – move backward to the first occurrence – move backward to the first occurrence
of string in the fileof string in the file
nn – repeat last searching – repeat last searching
NN – repeat last searching in opposite direction – repeat last searching in opposite direction
command mode – move in a filecommand mode – move in a file
source: Ling Zhu
55 Jan 24, 2005Jan 24, 2005
^D^D – scroll down half screen – scroll down half screen
^U^U – scroll up half screen – scroll up half screen
^F^F – scroll forward one full screen – scroll forward one full screen
^B^B – scroll backward one full screen – scroll backward one full screen
HH – move to the top of the screen – move to the top of the screen
MM – move to the middle of the screen – move to the middle of the screen
LL – move to the top of the screen – move to the top of the screen
command mode – move in a screencommand mode – move in a screen
source: Ling Zhu
66 Jan 24, 2005Jan 24, 2005
00 – move to the beginning of the line – move to the beginning of the line
$$ – move to the end of the line – move to the end of the line
fmfm – move forward to the first occurrence of – move forward to the first occurrence of
m on the linem on the line
3ff3ff – move forward to the third occurrence – move forward to the third occurrence
of f on the lineof f on the line
FnFn – move backward to the first occurrence – move backward to the first occurrence
of m on the lineof m on the line
3F43F4 – move backward to the third occurrence – move backward to the third occurrence
of 4 on the lineof 4 on the line
command mode – move on a linecommand mode – move on a line
source: Ling Zhu
77 Jan 24, 2005Jan 24, 2005
ww – move to the beginning of the next – move to the beginning of the next wordword
ee – move to the end of the next word – move to the end of the next word
bb – Move back to the beginning to the – Move back to the beginning to the previous word previous word
WW – move to the beginning of the next – move to the beginning of the next WORDWORD
EE – move to the end of the next WORD – move to the end of the next WORD
BB – Move back to the beginning to the – Move back to the beginning to the previous WORD previous WORD
command mode – move between wordscommand mode – move between words
source: Ling Zhu
delimited by any non-alphanumeric character
delimited by any
blank space
88 Jan 24, 2005Jan 24, 2005
{{ – move backward to the beginning of a paragraph – move backward to the beginning of a paragraph
}} – move forward to the end of a paragraph – move forward to the end of a paragraph
(( – move backward to the beginning of a sentence – move backward to the beginning of a sentence
)) – move forward to the end of a sentence – move forward to the end of a sentence
command mode – more movementcommand mode – more movement
source: Ling Zhu
99 Jan 24, 2005Jan 24, 2005
What would be the result of issuing What would be the result of issuing the following sequences of vi the following sequences of vi commands?commands?
<ESC>3k3Wd$<ESC>3k3Wd$
<ESC>k3laalt<ESC>k3laalt
<ESC>2kCmkdir<ESC>kill<ESC>2kCmkdir<ESC>kill
Can you answer?Can you answer?
source: Ling Zhu
1010 Jan 24, 2005Jan 24, 2005
J J – join two lines– join two lines
ZZZZ – exit and save any change – exit and save any change
.. – repeat last change – repeat last change
More about vi – command modeMore about vi – command mode
source: Ling Zhu
1111 Jan 24, 2005Jan 24, 2005
dwdw – delete to the beginning of the next word – delete to the beginning of the next word
d$d$ – delete to the end of the line – delete to the end of the line
d)d) – delete to the beginning of the next sentence – delete to the beginning of the next sentence
dtedte – delete till the next e – delete till the next e
dddd – delete the current line – delete the current line
Latest deleted text is saved in a buffer. Latest deleted text is saved in a buffer. How to put it?How to put it? pp – put the content before the cursor or line – put the content before the cursor or line
PP – put the content after the cursor or line – put the content after the cursor or line
vi command mode – cut and pastevi command mode – cut and paste
source: Ling Zhu
1212 Jan 24, 2005Jan 24, 2005
y10Gy10G – copy from here to line 10 – copy from here to line 10
y$y$ – copy to the end of the line – copy to the end of the line
yLyL – copy from here to the last line of the screen – copy from here to the last line of the screen
yy''aa – copy from here till the marked line a – copy from here till the marked line a
yyyy – copy the whole line – copy the whole line
Latest copied text is saved in a buffer. Latest copied text is saved in a buffer. How to put it?How to put it? pp – put the content before the cursor or line – put the content before the cursor or line
PP – put the content after the cursor or line – put the content after the cursor or line
Advanced vi – copy and pasteAdvanced vi – copy and paste
source: Ling Zhu
1313 Jan 24, 2005Jan 24, 2005
“ “adwadw – delete to the beginning of the next word – delete to the beginning of the next word
and saved to the buffer named aand saved to the buffer named a
“ “bd$bd$ – delete to the end of the line and saved to – delete to the end of the line and saved to
the buffer named bthe buffer named b
“ “cyLcyL – copy from here to the last line of the – copy from here to the last line of the
screen and saved to the buffer named cscreen and saved to the buffer named c
“ “dyydyy – copy the whole line to the buffer named d – copy the whole line to the buffer named d
How to put the latest text in buffer? How to put the latest text in buffer? “ “apap – put buffer a content before the cursor or line – put buffer a content before the cursor or line
“ “bPbP – put buffer b content after the cursor or line – put buffer b content after the cursor or line
Advanced vi – named bufferAdvanced vi – named buffer
source: Ling Zhu
1414 Jan 24, 2005Jan 24, 2005
^G ^G – display the status of the current file– display the status of the current file
^L^L – refresh screen – refresh screen
^Z^Z – suspend this job and return to the Unix – suspend this job and return to the Unix command line and command line and fg fg come back to the come back to the suspend jobsuspend job
~~ – convert case – convert case
Advanced vi – command modeAdvanced vi – command mode
source: Ling Zhu
1515 Jan 24, 2005Jan 24, 2005
:e:e– edit a file– edit a file
:!:!– execute commands without exit vi– execute commands without exit vi
Advanced vi – last line modeAdvanced vi – last line mode
source: Ling Zhu
1616 Jan 24, 2005Jan 24, 2005
..
Symbols for Special DirectoriesSymbols for Special Directories
source: Ling Zhu
your home directoryyour home directory
current working directorycurrent working directory
.... parent directoryparent directory
../..../.. grandparent directorygrandparent directory
~~ your home directoryyour home directory
$HOME$HOME
1717 Jan 24, 2005Jan 24, 2005
cp cp policypolicy destinationdestination
source: Ling Zhu
mv mv policypolicy destinationdestination
What if What if destinationdestination is a directory? is a directory?
What if there is a policy file under What if there is a policy file under destination?destination?
What if What if destinationdestination is a file that exists? is a file that exists?
What if What if destinationdestination is a file that doesn’t exist? is a file that doesn’t exist?
Can you answer the last four questions?Can you answer the last four questions?
Review last week commandsReview last week commands
1818 Jan 24, 2005Jan 24, 2005
What are the siz commands to view a What are the siz commands to view a file?file?
Why Why lessless can do more work then can do more work then moremore does?does?
Review last week commands Review last week commands
source: Ling Zhu
1919 Jan 24, 2005Jan 24, 2005
Which is the command to remove a file?Which is the command to remove a file?
Which is the command to rename a file?Which is the command to rename a file?
What is the difference betweenWhat is the difference between
rm -r rm -r and and rmdir rmdir ??
source: Ling Zhu
Review last week commandsReview last week commands
2020 Jan 24, 2005Jan 24, 2005
catcat Display the content of a file or multiple filesDisplay 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 Combine with >> to copy a file to copy a file Combine with Combine with >> to create a new file to create a new file
use ctrl+D to finishuse ctrl+D to finish Combine with Combine with >>>> to append to a file to append to a file
source: Ling Zhu
More Details of Commands LearnedMore Details of Commands Learned
2121 Jan 24, 2005Jan 24, 2005
mkdir -p mkdir -p
Make pass directories as needed.Make pass directories as needed.
ls –dls –d
List directory entries instead of contentsList directory entries instead of contents
rm –irm –i
Prompt before any removalPrompt before any removal
rm –rirm –ri
When delete directory with contents,When delete directory with contents,
prompt before any removalprompt before any removal
More Details of Commands LearnedMore Details of Commands Learned
source: Ling Zhu
Top Related