命令行大全

ex

rose1 发表于 2020-09-08 09:07浏览次数:

在类似Unix的操作系统上,ex命令是一个文本编辑器,以及vi的行编辑器模式。它是vim的基础,vim是世界上最受欢迎的文本编辑器之一。ex由比尔·乔伊(Bill Joy)在1976年根据查尔斯·海利(Charles Haley)编写的早期程序编写。

查看英文版

目录:

1 ex 运行系统环境

2 ex 说明

3 ex 语法

4 ex 例子

ex 运行系统环境

Linux

ex 说明

“ ex”表示扩展,因为它最初是简单的行编辑器ed的扩展。同样,“ vi”代表视觉,因为vi是“视觉”(全屏)编辑模式,最终被添加到ex。

命令exvi指向以不同模式启动的同一程序。您可以通过运行vi -e来启动ex,也可以通过运行ex -v来启动vi。另外,在ex内,您可以使用可视命令(或简称vi)启动vi。在vi内部,可以使用命令Q来启动ex

如果您熟悉vi,则可以在键入冒号(“ : ”)之后将ex命令提示符与vi的命令提示符相同。例如,ex命令“ w ”会将您的更改写入磁盘,就像“ :w ”vi中的更改写入磁盘。

有关使用行编辑器的更多详细信息,请参阅我们的ed文档,其中包含大量示例和教程。

"ex" stands for extended, because it was originally an extension of the simple line editor ed. Similarly, "vi" stands for visual, because vi is the "visual" (full-screen) editing mode, which was eventually added to ex.

The commands ex and vi point to the same program, started in different modes. You can start ex by running vi -e, or you can start vi by running ex -v. Additionally, from within ex, you can start vi with the visual command (or vi for short). From inside vi, you can start ex with the command Q.

If you are familiar with vi, you can think of the ex command prompt as being the same as vi's command prompt after you type a colon (":"). For instance, the ex command "w" will write your changes to disk, just as ":w" will write changes to disk in vi.

For more in-depth information about using a line editor, see our documentation of ed, which contains extensive examples and a tutorial.

查看英文版

查看中文版

ex 语法

ex [ -| -s ] [ -l ] [ -L ] [ -R ] [ -r [ file ] ] [ -t tag ] [ -v ] [ -V ] 
   [ -x ] [ -wn ] [ -C ] [ +command | -c command ] file

选件

-, -s 禁止所有交互式用户反馈。在处理编辑器脚本时,这很有用。
-l 设置用于编辑LISP程序。
-L 列出由于编辑器或系统崩溃而保存的所有文件的名称。
-R 只读模式;设置了只读标志,以防止意外覆盖文件。
-r file 编辑器或系统崩溃后编辑文件。(恢复发生崩溃时缓冲区中文件的版本。)
-t tag 编辑包含标签的文件,并将编辑器置于其定义位置。
-v 使用vi在显示编辑状态下启动。您可以通过输入vi命令本身来达到相同的效果。
-V 详细。当通过标准输入读取ex命令时,输入将被回显为标准错误。在shell 脚本中处理ex命令时,这可能很有用。
-x 加密选项。模拟X命令并提示用户输入密钥。该密钥用于使用crypt命令的算法对文本进行加密和解密。的X命令使一个受过教育的猜测,以确定文本是否在被加密或不读出。临时缓冲区文件也使用-x选项键入的键的转换版本进行加密。
-wn 将默认窗口大小设置为n。在较慢的速度线上使用编辑器时,这很有用。
-C 加密选项。与-x选项相同,但模拟C命令。该Ç命令是像X命令,除了所有文字,被认为已经加密阅读。
+command, -c command 过执行指定的编辑器命令(通常是搜索或定位命令)来开始编辑。
file 要编辑的文件名。
ex [ -| -s ] [ -l ] [ -L ] [ -R ] [ -r [ file ] ] [ -t tag ] [ -v ] [ -V ] 
   [ -x ] [ -wn ] [ -C ] [ +command | -c command ] file

Options

--s Suppress all interactive user feedback. This is useful when processing editor scripts.
-l Set up for editing LISP programs.
-L List the name of all files saved as the result of an editor or system crash.
-R Readonly mode; the readonly flag is set, preventing accidental overwriting of the file.
-r file Edit file after an editor or system crash. (Recovers the version of file that was in the buffer when the crash occurred.)
-t tag Edit the file containing the tag and position the editor at its definition.
-v Start up in display editing state using vi. You can achieve the same effect by typing the vi command itself.
-V Verbose. When ex commands are read by means of standard input, the input will be echoed to standard error. This may be useful when processing ex commands within shell scripts.
-x Encryption option. Simulates the X command and prompts the user for a key. This key is used to encrypt and decrypt text using the algorithm of the crypt command. The X command makes an educated guess to determine whether text read in is encrypted or not. The temporary buffer file is encrypted also, using a transformed version of the key typed in for the -x option.
-wn Set the default window size to n. This is useful when using the editor over a slow speed line.
-C Encryption option. Same as the -x option, except simulates the C command. The C command is like the X command, except that all text read in is assumed to have been encrypted.
+command, -c command Begin editing by executing the specified editor command (usually a search or positioning command).
file The name of a file to be edited.

查看英文版

查看中文版

ex 例子

ex myfile.txt

编辑文件myfile.txt。

ex myfile.txt

Edits the file myfile.txt.

查看英文版

查看中文版