← 返回命令列表

Linux command

ed 命令

文件

复制后可按需替换文件名、目录或参数。

常用示例

Start ed with

ed [file.txt]

Print line 5

5p

Print all lines

,p

Substitute text

s/old/new/

Substitute globally

s/old/new/g

Append after

a

Write and quit

wq

说明

ed is the standard Unix line editor. It operates in command mode by default, accepting single-letter commands to navigate, view, and modify text. It's the ancestor of sed and vi. Commands typically consist of an address or range followed by a command letter. Addresses can be line numbers, patterns, or special characters (. for current, $ for last line). ed is useful for scripted editing, as commands can be piped to it. Its minimal interface makes it valuable for emergency system recovery when full-screen editors aren't available.

参数

-p _STRING_
Set command prompt.
-s
Suppress diagnostics.
-G
Enable backwards compatibility.

FAQ

What is the ed command used for?

ed is the standard Unix line editor. It operates in command mode by default, accepting single-letter commands to navigate, view, and modify text. It's the ancestor of sed and vi. Commands typically consist of an address or range followed by a command letter. Addresses can be line numbers, patterns, or special characters (. for current, $ for last line). ed is useful for scripted editing, as commands can be piped to it. Its minimal interface makes it valuable for emergency system recovery when full-screen editors aren't available.

How do I run a basic ed example?

Run `ed [file.txt]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -p _STRING_ do in ed?

Set command prompt.