首页 > 代码库 > more和less编辑模式
more和less编辑模式
今天在用less浏览/etc/services里的服务端口时无意中发现。在less查看文件的同时居然可以进入VI模式编辑原文件。经过测试,more也有相同的功能。我搜索了百度和google好像没有人发现和发表过这内容。以后我们可以先用less浏览文件再修改会不会更好呢?
希望发出来和中国的linuxer可以共享学习一下。
有什么不对之处,敬请谅解。也可以接受轻喷!
这里为方便看我显示了行号,可以看出左下角显示的是文件名‘services’处于浏览阶段。
[root@sean2 tmp]# less -N services
1 # /etc/services:
2 # $Id: services,v 1.48 2009/11/11 14:32:31 ovasik Exp $
3 #
4 # Network services, Internet style
5 # IANA services version: last updated 2009-11-10
6 #
7 # Note that it is presently the policy of IANA to assign a single well-kn 7 own
8 # port number for both TCP and UDP; hence, most entries here have two ent 8 ries
9 # even if the protocol doesn‘t support UDP operations.
10 # Updated from RFC 1700, ``Assigned Numbers‘‘ (October 1994). Not all po 10 rts
11 # are included, only the more common ones.
12 #
13 # The latest IANA port assignments can be gotten from
14 # http://www.iana.org/assignments/port-numbers
15 # The Well Known Ports are those from 0 through 1023.
16 # The Registered Ports are those from 1024 through 49151
17 # The Dynamic and/or Private Ports are those from 49152 through 65535
18 #
19 # Each line describes one service, and is of the form:
20 #
21 # service-name port/protocol [aliases ...] [# comment]
22
services
这里按下v就进入了Vi模式,左下出现了总行数。如下:
# /etc/services:
# $Id: services,v 1.48 2009/11/11 14:32:31 ovasik Exp $
#
# Network services, Internet style
# IANA services version: last updated 2009-11-10
#
# Note that it is presently the policy of IANA to assign a single well-known
# port number for both TCP and UDP; hence, most entries here have two entries
# even if the protocol doesn‘t support UDP operations.
# Updated from RFC 1700, ``Assigned Numbers‘‘ (October 1994). Not all ports
# are included, only the more common ones.
#
# The latest IANA port assignments can be gotten from
# http://www.iana.org/assignments/port-numbers
# The Well Known Ports are those from 0 through 1023.
# The Registered Ports are those from 1024 through 49151
# The Dynamic and/or Private Ports are those from 49152 through 65535
#
# Each line describes one service, and is of the form:
#
# service-name port/protocol [aliases ...] [# comment]
tcpmux 1/tcp # TCP port service multiplexer
tcpmux 1/udp # TCP port service multiplexer
rje 5/tcp # Remote Job Entry
"services" 10774L, 641020C
20行是个空行,我在这行加入字符,保存退出看源文件是否被修改。
3 #
4 # Network services, Internet style
5 # IANA services version: last updated 2009-11-10
6 #
7 # Note that it is presently the policy of IANA to assign a single well-kn own
8 # port number for both TCP and UDP; hence, most entries here have two ent ries
9 # even if the protocol doesn‘t support UDP operations.
10 # Updated from RFC 1700, ``Assigned Numbers‘‘ (October 1994). Not all po rts
11 # are included, only the more common ones.
12 #
13 # The latest IANA port assignments can be gotten from
14 # http://www.iana.org/assignments/port-numbers
15 # The Well Known Ports are those from 0 through 1023.
16 # The Registered Ports are those from 1024 through 49151
17 # The Dynamic and/or Private Ports are those from 49152 through 65535
18 #
19 # Each line describes one service, and is of the form:
20 # I am here,this is a test line.
21 # service-name port/protocol [aliases ...] [# comment]
22
23 tcpmux 1/tcp # TCP port service multip lexer
-- INSERT --
用vi进入文件查看。文件确实已被修改!
[root@sean2 tmp]# vim services
1 # /etc/services:
2 # $Id: services,v 1.48 2009/11/11 14:32:31 ovasik Exp $
3 #
4 # Network services, Internet style
5 # IANA services version: last updated 2009-11-10
6 #
7 # Note that it is presently the policy of IANA to assign a single well-know n
8 # port number for both TCP and UDP; hence, most entries here have two entri es
9 # even if the protocol doesn‘t support UDP operations.
10 # Updated from RFC 1700, ``Assigned Numbers‘‘ (October 1994). Not all port s
11 # are included, only the more common ones.
12 #
13 # The latest IANA port assignments can be gotten from
14 # http://www.iana.org/assignments/port-numbers
15 # The Well Known Ports are those from 0 through 1023.
16 # The Registered Ports are those from 1024 through 49151
17 # The Dynamic and/or Private Ports are those from 49152 through 65535
18 #
19 # Each line describes one service, and is of the form:
20 # I am here,this is a test line.
21 # service-name port/protocol [aliases ...] [# comment]
22
:set nu
本文出自 “泥巴” 博客,请务必保留此出处http://niba666.blog.51cto.com/9238216/1868191
more和less编辑模式