I've not being able to find a post with this requirement. I'm using Python. I need to delete a line from a file only if next line starts with the characters "-----a".
If next line starts with spaces (or different characters) the line musn't be deleted.
Example:
-----arn:aws:iam::001122334455:policy/policy_name1 # delete this
-----arn:aws:iam::001122334455:policy/policy_name2 # delete this
-----arn:aws:iam::001122334455:policy/policy_name3 # delete this
-----arn:aws:iam::001122334455:policy/policy_name4 # delete this
-----arn:aws:iam::001122334455:policy/policy_name5 # do NOT delete this line
"Action": "s3:*", # do NOT delete this line either
-----arn:aws:iam::001122334455:policy/policy_name6 # delete this
-----arn:aws:iam::001122334455:policy/policy_name7 # delete this
I'm kinda new to Python and I'm being unable to find a way to do this. Any help will be much appreciated!