例如:在VIM中,
test
sample replace
test1
replace
sample test2
Run Code Online (Sandbox Code Playgroud)
:g/sample/s/replace/test3/ - 只会在匹配的行中用"sample"替换"replace"
test
sample test3
test1
replace
sample test2
Run Code Online (Sandbox Code Playgroud)
在VIM中,只能在非匹配行上替换,可以通过以下方式完成:v/sample/s/replace/test3 - 仅在不包含"sample"的非匹配行上替换"replace"
test
sample replace
test1
test3
sample test2
Run Code Online (Sandbox Code Playgroud)
如何使用emacs完成上述事情?
我正在尝试阅读特定文件的内容.我有多个这些文件所在的主机.我在ssh期间传递下面的命令,以便它可以运行并获得输出.
使用下面的命令时,我得到指定的错误.(它主宰但没有任何反应)
$ ssh host "more $(find /my/path -name "test*")"
find: 0652-010 The starting directory is not valid.
Run Code Online (Sandbox Code Playgroud)当使用exec它不工作时,(它的sshed主机但没有任何反应)
$ ssh host "find /my/path -name "test*" -exec more {} \;"`
Run Code Online (Sandbox Code Playgroud)使用xargs时,它按预期工作
$ ssh host "find /my/path -name "test*" | xargs more"
Run Code Online (Sandbox Code Playgroud)有人可以解释为什么方法1和2不起作用?
请注意,如果我在远程主机上直接运行命令,则每种方法都有效.例如,以下所有命令在远程主机中按预期工作.
more $(find /my/path -name "test*")
find /my/path -name "test*" -exec more {} \;
find /my/path -name "test*" | xargs more
Run Code Online (Sandbox Code Playgroud)