Watnog
asked on
unix sed: delete first ocurrence after pattern
Dear Experts,
In a file I need to delete lines.
Each line in which there is PRIORITY must be removed but only if it is first occurence after the word SCHEDULE.
So if I have this:
Should becomes this...
An other way to see it is that every line that contains PRIORITY between [SCHEDULE] and [:]
is to be deleted.
The goal here is to remove priorities set on schedule level.
Thanks again for your appreciated help.
In a file I need to delete lines.
Each line in which there is PRIORITY must be removed but only if it is first occurence after the word SCHEDULE.
So if I have this:
SCHEDULE WKS#SOTS-TEST
PRIORITY 85
:
WKS#OTS-EXIT0-CMD
PRIORITY 20
END
SCHEDULE WKS#SOTS-TEST1
ON RUNCYCLE TC TC-SUTH
PRIORITY 70
:
WKS#OTS-EXIT1-CMD
PRIORITY 30
END
PRIORITY 85
:
WKS#OTS-EXIT0-CMD
PRIORITY 20
END
SCHEDULE WKS#SOTS-TEST1
ON RUNCYCLE TC TC-SUTH
PRIORITY 70
:
WKS#OTS-EXIT1-CMD
PRIORITY 30
END
Should becomes this...
SCHEDULE WKS#SOTS-TEST
ON RUNCYCLE TC TC-SUTH
:
WKS#OTS-EXIT0-CMD
PRIORITY 20
END
SCHEDULE WKS#SOTS-TEST1
:
WKS#OTS-EXIT1-CMD
PRIORITY 30
END
ON RUNCYCLE TC TC-SUTH
:
WKS#OTS-EXIT0-CMD
PRIORITY 20
END
SCHEDULE WKS#SOTS-TEST1
:
WKS#OTS-EXIT1-CMD
PRIORITY 30
END
An other way to see it is that every line that contains PRIORITY between [SCHEDULE] and [:]
is to be deleted.
The goal here is to remove priorities set on schedule level.
Thanks again for your appreciated help.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you wmp!