我有一个简单的邮件,我需要删除Summary of client activity for the last 24 hours
之前的所有内容我认为它最适合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
...
答案 0 :(得分:2)
很容易:
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
..
答案 1 :(得分:0)
您可以使用sed地址范围不打印从第一个到模式的所有行
$ sed -n '1, /Summary of client activity for the last 24 hours/!p;
DomainNodenamePlatformTypeActivityData amountElapse timeAffectedFailedMedia wait
-FILESYSTEM-ABSYNTHE-Linux x86-64-XFS-
BACKUP-
337.5 MB-
00:00-
60-
0-
0
...
要包含Summary...
行,
$ sed -n '1, /Summary of client activity for the last 24 hours/!p; /Summary of client activity for the last 24 hours/p' test
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
...