Latest web development tutorials

Linux ed command

Linux command Daquan Linux command Daquan

Linux ed command is a text editor for text editing.

ed in Linux is the most simple text editing program, edit line only once, rather than operating full-screen mode.

ed command is not a commonly used commands, more is generally used vi commands. But ed text editor to edit large files or to edit text in a shell script is useful.

grammar

ed [-][-Gs][-p<字符串>][--help][--version][文件] 

Parameters:

  • -G Or --traditional provide back-compatible functions.
  • -p <string> Specifies ed in command mode prompt character.
  • -s, -, - quiet or --silent not perform checks when the file is turned on.
  • --help displays help.
  • --version display version information.

Examples

The following is a complete example of parsing Linux ed:

$ ed              <- 激活 ed 命令 
a                 <- 告诉 ed 我要编辑新文件 
My name is Titan. <- 输入第一行内容 
And I love Perl very much. <- 输入第二行内容 
.                 <- 返回 ed 的命令行状态 
i                 <- 告诉 ed 我要在最后一行之前插入内容 
I am 24.          <- 将“I am 24.”插入“My name is Titan.”和“And I love Perl very much.”之间 
.                 <- 返回 ed 的命令行状态 
c                 <- 告诉 ed 我要替换最后一行输入内容 
I am 24 years old. <- 将“I am 24.”替换成“I am 24 years old.”(注意:这里替换的是最后输的内容) 
.                 <- 返回 ed 的命令行状态 
w readme.text     <- 将文件命名为“readme.text”并保存(注意:如果是编辑已经存在的文件,只需要敲入 w 即可) 
q                 <- 完全退出 ed 编辑器 

This is the contents of the file are:

$ cat readme.text 
My name is Titan. 
I am 24 years old. 
And I love Perl vrey much. 

Linux command Daquan Linux command Daquan