Is it possible to get the help for a k8s command but only show the Examples section of the help?
For example, if I run:
kubectl run --help
It outputs different sections, but I only want to see examples on the screen.
CodePudding user response:
This command only show line 2 to line 30
kubectl run --help | head -n30 | tail -n28
CodePudding user response:
Like many other help pages, K8s help docs come in this order:
- Description
- Examples
- Options
- Usage
you could use sed to cut out the part you need:
kubectl run --help | sed -n "/Examples:/,/Options:/p"
or better:
kubectl run --help | sed -n "/Examples:/,/Options:/p" | grep -v "Options:"