Files
tldr/pages.zh/common/^.md
2024-10-12 15:05:34 -07:00

22 lines
638 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Caret
> Bash 内置命令,用于快速替换上一个命令中的字符串并运行结果。
> 等效于 `!!:s^string1^string2`。
> 更多信息:<https://gnu.org/software/bash/manual/bash.html#Event-Designators>.
- 运行上一个命令,将 `字符串 1` 替换为 `字符串 2`
`^{{字符串 1}}^{{字符串 2}}`
- 从上一个命令中移除 `字符串 1`
`^{{字符串 1}}^`
- 在上一个命令中将 `字符串 1` 替换为 `字符串 2`,并在其末尾添加 `字符串 3`
`^{{字符串 1}}^{{字符串 2}}^{{字符串 3}}`
- 替换所有出现的 `字符串 1`
`^{{字符串 1}}^{{字符串 2}}^:&`