Grep from A to B
Publish date: Jul 31, 2019
Grepping multiple lines
I use to grep for multiple lines using grep -A as follows
kubectl describe pod <podname> -n <namespace> | grep -A7 ConditionsConditions:
Type Status
Initialized True
Ready True
ContainersReady True
PodScheduled True
Volumes:
It returns 7 lines counting from the matched word “Conditions”.
Get Text Between Two Keywords
Sometimes we want to grep for a words between two keywords.
kubectl describe pod <podname> -n <namespace> | sed -n -e '/Conditions/,/Volumes/p'Conditions:
Type Status
Initialized True
Ready True
ContainersReady True
PodScheduled True
Volumes: