gpt4 book ai didi

bash - SED 删除字符串前的所有内容

转载 作者:行者123 更新时间:2023-12-05 03:09:52 26 4
gpt4 key购买 nike

我有一个普通邮件,我需要在 过去 24 小时的客户端事件摘要之前删除所有内容
我认为它最适合 sed。

我在互联网上搜索过,但那里只有一个分隔符或类似的东西。

你有什么想法吗?

部分邮件:

...(Personal Part of the Email)...
...
The following clients have no associated schedule
NodeDomainContact
-KABA-FILESYSTEM-
-USTICA-FILESYSTEM-

Summary of client activity for the last 24 hours
DomainNodenamePlatformTypeActivityData amountElapse timeAffectedFailedMedia wait
-FILESYSTEM-ABSYNTHE-Linux x86-64-XFS-
BACKUP-
337.5 MB-
00:00-
60-
0-
0
...

期望的输出:

Summary of client activity for the last 24 hours
DomainNodenamePlatformTypeActivityData amountElapse timeAffectedFailedMedia wait
-FILESYSTEM-ABSYNTHE-Linux x86-64-XFS-
BACKUP-
337.5 MB-
00:00-
60-
0-
0
...

最佳答案

使用 awk:

awk '/Summary of client activity for the last 24 hours/{p=1}p' file

或者 sed:

sed -n '/Summary of client activity for the last 24 hours/,$p' file

使用 awk 测试您的电子邮件示例(上面的 sed cmd 具有相同的输出):

kent$  cat f
...(Personal Part of the Email)...
...
The following clients have no associated schedule
NodeDomainContact
-KABA-FILESYSTEM-
-USTICA-FILESYSTEM-

Summary of client activity for the last 24 hours
DomainNodenamePlatformTypeActivityData amountElapse timeAffectedFailedMedia wait
-FILESYSTEM-ABSYNTHE-Linux x86-64-XFS-
BACKUP-
337.5 MB-
00:00-
60-
0-
0
...

kent$ awk '/Summary of client activity for the last 24 hours/{p=1}p' f
Summary of client activity for the last 24 hours
DomainNodenamePlatformTypeActivityData amountElapse timeAffectedFailedMedia wait
-FILESYSTEM-ABSYNTHE-Linux x86-64-XFS-
BACKUP-
337.5 MB-
00:00-
60-
0-
0
..

关于bash - SED 删除字符串前的所有内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41591112/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com