示例任务:如果一行包含foo
,则将其替换为bar
,否则附加baz
到该行。
sed -e s/foo/bar/ -e s/$/baz/
不起作用,因为无论第一个命令是否匹配,都会执行第二个命令。有没有办法告诉sed
比赛结束后转到下一行?
我试图netconsole
在我的家用 PC上启用,但是在我的桥接 LAN 和 Wi-Fi 上遇到了一些问题。
如果我不指定接口名称,则会失败,如下所示:
$ sudo modprobe netconsole netconsole=6666@192.168.0.1/,6666@192.168.0.2/A0:F3:C1:FF:4C:70
modprobe: ERROR: could not insert 'netconsole': No such device
Run Code Online (Sandbox Code Playgroud)
dmesg 输出:
netpoll: netconsole: local port 6666
netpoll: netconsole: local IPv4 address 192.168.0.1
netpoll: netconsole: interface 'eth0'
netpoll: netconsole: remote port 6666
netpoll: netconsole: remote IPv4 address 192.168.0.2
netpoll: netconsole: remote ethernet address a0:f3:c1:ff:4c:70
netpoll: netconsole: eth0 doesn't exist, aborting
netconsole: cleaning up
Run Code Online (Sandbox Code Playgroud)
它尝试查找eth0
并失败,很可能是因为 systemd 将其重命名为enp9s0
.
如果我明确指定新接口名称:
$ sudo modprobe netconsole netconsole=6666@192.168.0.1/enp9s0,6666@192.168.0.2/A0:F3:C1:FF:4C:70
modprobe: …
Run Code Online (Sandbox Code Playgroud)我正在尝试设置 SSH 多路复用,但我遇到了一个错误,并且在 Google 上有 0 次点击以获得确切的错误消息。
我~/.ssh/config
用内容创建:
Host *
ControlPath ~/.ssh/master-%r@%h:%p
Run Code Online (Sandbox Code Playgroud)
然后,我通过运行创建了主连接:
ssh -vMM user@host.example.com
Run Code Online (Sandbox Code Playgroud)
这似乎成功创建了多路复用套接字:
...
Authenticated to host.example.com ([1.2.3.4]:22).
debug1: setting up multiplex master socket
debug1: channel 0: new [/home/user/.ssh/master-user@host.example.com:22]
debug1: channel 1: new [client-session]
debug1: Entering interactive session.
...
Run Code Online (Sandbox Code Playgroud)
然后,我尝试在另一个窗口中通过 ssh 运行命令:
ssh -v user@host.example.com ls
Run Code Online (Sandbox Code Playgroud)
但是,这似乎无法使用多路复用套接字:
OpenSSH_7.5p1, OpenSSL 1.1.0f 25 May 2017
debug1: Reading configuration data /home/user/.ssh/config
debug1: /home/user/.ssh/config line 1: Applying options for *
debug1: Reading configuration data /etc/ssh/ssh_config
Master refused session …
Run Code Online (Sandbox Code Playgroud) 我想让我的终端 (rxvt-unicode) 的Terminfo正常工作,以便当我从 Linux ssh 到 macOS 时,Home/End 和其他键可以正常工作。
通常,要使用 Linux 远程主机完成此操作,我会使用如下脚本:
ssh "$1" 'mkdir -p ~/.terminfo/r'
for f in /usr/share/terminfo/r/rxvt-unicode{,-256color}
do
scp "$f" "$1":.terminfo/r/
done
Run Code Online (Sandbox Code Playgroud)
但是,这不适用于 macOS。
当我运行时screen
,首先我收到“TERM 太长 - 抱歉。”。
将其更新到 brew 版本 (4.06.02) 后,我现在收到“无法找到 'rxvt-unicode-256color' 的 terminfo 条目。”
TERM
正确设置为rxvt-unicode-256color
,并且~/.terminfo/r/rxvt-unicode-256color
存在。
跑步screen
用TERMINFO=$HOME/.terminfo/
也没有效果。