小编Edu*_*ani的帖子

用另一个字符串替换许多字符串

我想在忽略某些命令的同时运行 shell 脚本,因为它们需要特权。像这样的命令insmod。所以我用这个过滤脚本,它可以工作(这些命令被替换为true):

sed -e 's/command1/true/g' -e 's/command2/true/g' -e 's/command3/true/g' ... -e 's/commandN/true/g'
Run Code Online (Sandbox Code Playgroud)

有没有更简洁的表达方式?

使用简单的字符,要将 'a'、'b' 和 'm' 更改为 'x',我可以执行以下操作:

sed -e 's/[abm]/x/g'
Run Code Online (Sandbox Code Playgroud)

或者

tr abm x
Run Code Online (Sandbox Code Playgroud)

(或其tr abm '[x*]'POSIX 等价物)。但是用字符串?

sed text-processing regular-expression

6
推荐指数
1
解决办法
177
查看次数

将 NTP 机器与高根时间服务器同步

我有一个小型机器网络,systemd-timesyncd.service它们使用并需要同步时钟。它们不需要正确,只需同步即可。我已将其中一台机器指定为 NTP 服务器,其余机器都指向这台机器,但它们需要几个小时才能同步,而且当它们同步时,会出现非常不一致的情况:

Jun 22 18:09:16 host systemd-timesyncd[10515]: Initial synchronization to time server 10.10.1.30:123 (10.10.1.30).
Jun 22 18:25:50 host systemd-timesyncd[10515]: Server has too large root distance. Disconnecting.
Jun 22 18:34:22 host systemd-timesyncd[10515]: Server has too large root distance. Disconnecting.
Jun 22 18:51:26 host systemd-timesyncd[10515]: Server has too large root distance. Disconnecting.
Jun 22 19:25:34 host systemd-timesyncd[10515]: Server has too large root distance. Disconnecting.
Jun 22 19:59:43 host systemd-timesyncd[10515]: Server has too large root distance. Disconnecting.
Jun 22 20:33:51 …
Run Code Online (Sandbox Code Playgroud)

systemd ntp

2
推荐指数
1
解决办法
8268
查看次数

标签 统计

ntp ×1

regular-expression ×1

sed ×1

systemd ×1

text-processing ×1