Saturday, May 23, 2020

Tip: find sed awk egrep

find ./ -type f -exec sed -i -e 's/oldstring/newstring/g' {} \;
find ./ -name *.yaml | while read -r filename; do echo "test" >> "$filename"; done
kubectl get rolebindings  --all-namespaces |egrep 'strings1|strings' |grep psp |awk '{print $2" -n "$2 }'

Goal: convert string from "adc@adc.com  ocid.aa******" to
"
- apiGroup: rbac.authorization.k8s.io 
  kind: User 
  name: ocid.aa*** # adc@adc.com
"
Tip:
Put all strings in 1.txt
cat 1.txt  | while read -r line; do echo $line | awk '{print "- apiGroup: rbac.authorization.k8s.io","\n", " kind: User","\n"," name: "$2" # "$1, "\n"}'; done


No comments: