Reputation: 127
I have a plain Mail and i need to remove everything before Summary of client activity for the last 24 hours
i thought it would work best with sed.
I searched the internet but there it's just with a delimiter or something similar.
You have any ideas?
Part of the Mail:
...(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
...
Desired Output:
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
...
Upvotes: 4
Views: 19344
Reputation: 195029
Using awk:
awk '/Summary of client activity for the last 24 hours/{p=1}p' file
Or sed:
sed -n '/Summary of client activity for the last 24 hours/,$p' file
Test with your email example with awk (sed cmd above has same output):
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
..
Upvotes: 5
Reputation: 26667
You can use sed address range to not print all lines from first to the pattern as
$ 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
...
To include the Summary...
line as well,
$ 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
...
Upvotes: 0