Reputation: 4590
How to remove a line which has this pattern using sed
resourceNames: [""]
I tried
sed -i '/resourceNames: [""]/d' ./sa.yaml
A part of file looks like this
- apiGroups: [""]
resources: ["secrets"]
resourceNames: [""]
verbs: ["get"]
---
Upvotes: 4
Views: 849
Reputation: 12438
A better and more robust regex for your sed
command:
sed -i '/\s*resourceNames:\s*\[""\]/d' ./sa.yaml
where you just escape the []
to avoid them being interpreted as character range, character list also, instead of space it is better to use \s*
Upvotes: 1
Reputation: 4590
Alright.I found the issue in my code. This worked
sed -i '/ resourceNames: [[]""[]]/d' ./sa.yaml
Upvotes: 2