文本处理CLI Manual
$sed
Stream editor for filtering and transforming text using pattern substitutions.
命令语法POSIX Standard
sed [OPTIONS] SCRIPT [INPUT-FILE...]在交互式终端沙盒中实时运行
无需安装的客户端实时仿真环境。
bash — terminal
AST Sandbox (Free)
概述与工作原理
`sed` (Stream Editor) performs basic text transformations on an input stream or file. Its most famous capability is search-and-replace using the `s/find/replace/g` syntax, allowing automated batch editing of source code and configurations without opening a visual editor.
常用参数与选项说明
| Flag / Option | Description |
|---|---|
| -i | Edit files in place directly instead of printing to stdout. |
| -e [script] | Add the script to the commands to be executed. |
| -n | Suppress automatic printing of pattern space. |
实际生产案例与代码范例
#1Substitute string patterns in text output
echo "localhost:3000" | sed "s/3000/8080/g"Replaces port 3000 with 8080 in the stream.
相关 Linux 常用命令
$grep文本处理
使用正则表达式或匹配字符串在文本文件与输出流中搜索内容。
$head文本处理
Output the first part (top lines) of text files.
$tail文本处理
Output the last part (bottom lines) of files or stream real-time logs.
$wc文本处理
Print newline, word, and byte counts for files.
$echo文本处理
Print text strings or write data to files using shell redirection.
$awk文本处理
Pattern scanning and column text processing language.