I have a file test.txt
---
kind: ClusterRole
metadata:
kind: ClusterRoleBinding
metadata:
subjects:
roleRef:
kind: ClusterRole
name: bla
And need this output with sed (just the line that matches the exact pattern)
kind: ClusterRole
metadata:
sed -n '/kind: ClusterRole/,/metadata/p' test.txt
kind: ClusterRole
metadata:
kind: ClusterRoleBinding
metadata:
kind: ClusterRole
name: bla
is showing ClusterRole, ClusterRoleBinding and additional indented ClusterRole
sed -n '/kind: ClusterRole\b/,/metadata/p' test.txt
sed -n '/\<kind: ClusterRole\>/,/metadata/p' test.txt
Both of the above output to nothing what am I doing wrong? just so it's clear and I'm not getting any grep -B 2 suggestions ;-) this is an example file, the original file is a lot bigger and has hundreds of ClusterRoles so I need to figure out how to match the exact pattern.
Thank you!
lema