Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
SEEM 3460
SEEM 3460
Shell (cont)
SEEM 3460
Shell Operations
SEEM 3460
Shell Operations
Shell Operations
cp src dest
Example: ls *.c
SEEM 3460
Shell Operations
SEEM 3460
Shell Operations
SEEM 3460
10
11
Two files in the same directory may not have the same
name, although its perfectly OK for several files in
different directories to have the same name.
For example, this diagram shows a small hierarchy that
contains a ksh process and three files called myFile.
12
/home/glass/myFile
/home/myFile
/bin/myFile
SEEM 3460
13
Meaning
~wlam
~/
~/distribute/
SEEM 3460
14
Field
Meaning
current directory
..
parent directory
SEEM 3460
15
Relative PathName
myFile
../myFile
../../bin/myFile
SEEM 3460
16
17
18
cuse93:> ls
heart
cuse93:> ls -l heart
-rw-r--r-- 1 glass 106
19
SEEM 3460
20
Meaning
-rw-r--r--
glass
106
Jan 30 19:46
heart
SEEM 3460
21
22
Listing A File:
cat/more/page/head/tail
23
Listing A File:
cat/more/page/head/tail (cont)
24
Listing A File:
cat/more/page/head/tail (cont)
25
SEEM 3460
26
Wildcard
Meaning
[..]
SEEM 3460
27
SEEM 3460
28
Renaming A File: mv
SEEM 3460
rename to heart.ver1.
29
30
31
32
Moving To A Directory : cd
33
34
cuse93:> pwd
/home/glass/lyrics
cuse93:> cd ..
cuse93:> pwd
/home/glass
cuse93:>
SEEM 3460
35
Copying A File : cp
36
SEEM 3460
37
38
39
Deleting A File : rm
SEEM 3460
40
cuse93:> cd lyrics.draft
move to lyrics.draft directory
cuse93:> rm heart.ver1 heart.ver2 heart.ver3 heart.ver4 heart.ver5
cuse93:> ls
nothing remains.
cuse93:>
SEEM 3460
41
SEEM 3460
42
SEEM 3460
43
SEEM 3460
44
SEEM 3460
45
SEEM 3460
46
47
SEEM 3460
end of input.
48
49
SEEM 3460
50
51
General Command
[Ctrl]
[Ctrl]
[Ctrl]
[Ctrl]
o
x
t
j
[Ctrl]
[Ctrl]
[Ctrl]
[Ctrl]
Move
Move
Move
Move
SEEM 3460
52
Starting emacs
To start emacs with a blank file, enter the command
emacs with no parameters. To edit an existing file, specify
its name as a command line parameter. Assuming that
you supply no parameters, your screen will initially look
something like the figure below, depending on your
version of emacs.
Example of
starting emacs.
53
Ill draw screens that are only about six lines long to
conserve space. The second-from bottom line is called the
mode line and contains information in the following leftto- right order:
If the first three dashes contain a then the current file has
been modified.
The name that follows Emacs: is the name of the current
file. If no file is currently loaded, the name *scratch* is used
instead.
The current editing mode is then shown between
parentheses. In this case, its Fundamental, which is the
standard editing mode.
The next entry indicates your relative position in the file as a
percentage of the entire file. If the file is very small and fits
completely on the screen, then All is displayed. If youre at
the top or the bottom of a file, then Top and Bot are
respectively displayed.
SEEM 3460
54
emacs Commands
Unlike vim, emacs doesnt distinguish between text entry
mode and command mode. To enter text, simply start
typing. The initial emacs welcome banner automatically
disappears when you type the first letter. Long lines are
not automatically broken, so you must press the Enter key
when you wish to start a new line. Lines longer than the
width of the screen are indicated by a \ character at the
end of the screen, with the remainder of the line wrapped
onto the next line, as shown below.
This is a very long line that illustrates the way that unbroken lines a \
re displayed.
This is a much shorter line.
Emacs: *scratch*
(Fundamental) -- All
55
Control-H t
means Press and hold the Control key and then press the H key.
(For control sequences, it doesnt matter whether you use
uppercase or lowercase, so I suggest that you use lowercase, as
its easier.) Then release both keys and press the t key on its
own. Similarly, metasequences use the Esc key. For example,
the sequence
Esc x
means Press the Esc key (but dont hold it) and then press the x
key. The next few sections contain many examples of emacs
command sequences. If you ever accidentally press Esc followed
by Esc, emacs warns you that youre trying to do something
advanced and suggests that you press the n key to continue.
Unless youre a seasoned emacs user, its good advice.
SEEM 3460
56
SEEM 3460
57
Getting Help
There are several ways to obtain help information
about emacs. One of the best ways to get started
with emacs is to read the self-describing help
tutorial. I suggest that you do this before anything
else. To read the tutorial, use the command
sequence Control-H t. The tutorial will appear and
give you directions on how to proceed.
Leaving emacs
To leave emacs and save your file, use Control-X
Control-C. If you havent saved your file since it was
last modified, youll be asked whether you want to
save it.
SEEM 3460
58
emacs Modes
emacs supports several different modes for entering text.
including Fundamental, Lisp Interaction, and C. Each
mode supports special features that are customized for
the particular kind of text that youre editing. emacs starts
in Fundamental mode by default; Ill use that mode during
my description of emacs. For more information about
modes, consult the emacs tutorial.
Entering Text
To enter text, simply start typing. For example, the
following shows a short four-line poem. The next section
describes the editing features of emacs that allowed me
to change this poem to something a little better.
59
60
Key sequence
Up one line
Control-P (previous)
Control-N (next)
To start of line
To end of line
Control-E (end)
Esc b (back)
Esc f (forward)
Control-V
Up one screen
Esc v
Start of file
Esc <
End of file
Esc>
SEEM 3460
61
62
Item to delete
Key sequence
<delete> key
Control-D
Esc <delete>
Esc d
Control-K
Sentence
Esc k
You may undo editing actions one at a time by typing Control-X u for each
action that you wish to undo.
The following table shows a summary of the kill buffer and undo
commands.
Action
Key sequence
Control-Y
Esc y
Esc Control-W
Undo.
Control-X u
SEEM 3460
63
Searching
emacs allows you to perform something called an incremental
search. To search for ward from your current cursor position for a
particular sequence of letters, type Control-S. The prompt Isearch: is displayed on the bottom line of the screen, indicating
that emacs wants you to enter the string that you wish to search
for. As you enter the character sequence, emacs searches to find
the string nearest to your initial cursor position that matches
what youve entered so far; in other words, partial sub strings are
found as you enter the full string. To terminate the search and
leave your cursor at its current position, press Esc. If you delete
characters in the full string before pressing the Esc key, emacs
moves back to the first match of the remaining sub string. To
repeat a search, dont press Esc, but instead press Control-S to
search forward or Control-R to search backward.
Action
Key sequence
Control-S str
Control-R str
Control-S
Control-R
Esc
SEEM 3460
64
To save your file and then quit emacs, type ControlX Control-C.
Action
Key sequence
Control-X Control-S
Control-X Control-F
Control-X Control-C
Saving and
loading files in
emacs.
Miscellaneous
To redraw the screen, type Control-L. To place
emacs into auto-wrap mode, which automatically
inserts line breaks when words flow past the end of
a line, type Esc x auto-fill-mode and press Enter. To
leave this mode, repeat the command.
SEEM 3460
66