代码搜索结果
找到约 10,000 项符合
L 的代码
l20.2a
#print
You can now change a line of a file by a slow procedure: delete the
old version and insert the new one. For example, you could replace
line 4 of a file with
4d
3a
new version of line
l15.1a
#print
So far you only know how to copy and print existing files in the editor,
and not how to get started from scratch. The 'a' (append) command lets
you type in new text. For example, the sequence
l39.1a
#print
Using the "^" character, you can easily put things
at the beginnings of lines. For example
s/^/***/
puts "***" at the beginning of the line. Now edit
the file "text" and put the symbol '='
l51.2a
#print
You can also use relative addresses of the +1 or -1
sort with context searches. For example, to print the
line after the line containing "cat", you could say
/cat/+1p
Here is a file "text"
l62.2a
#print
A very useful command in the UNIX editor
is the 'm' command, which moves a lot of
lines from one place to another in a file. For example,
5,10m20
picks up lines 5 through 10 and moves them a
l31.1a
#print
A convenient abbreviation for the command '1,$p'
is simply '%', which just prints the contents
of a file.
In this directory there is a file named 'tree'.
Print the contents with the command ab
l6.2a
#print
How does the editor choose a line to print?
It always remembers a 'current line', which
is the last line of the file originally,
but you can choose any line you want. The command
3p
prints t
l45.1a
#print
There is one last class of substitutions that
you should know about: converting one line
into two or more by substituting a newline
into the middle. Suppose you want to split the line
Now
l43.1a
#print
Note that there is quite a list of special characters
recognized by the editor:
. [ * ^ $ & /
What do you do when you want to specifically use
one of these characters as itself, rather than
fo
l11.1a
#print
By now you are probably wondering how you
get into the editor if someone else doesn't put
you there. The main command interpreter (the shell)
recognizes
ex
as the name of the editor.
You can