I would like to edit a huge single line file with thousands of occurrences of some string 'string_string':
until the next appearance of a comma ,
(including this comma) and removing those occurrences from the file.
I assume that either sed
or awk
can be used to do that. They are advertised as tools to manipulate strings/character streams but also to be more applicable for multiline files.
Since both awk
and sed
commands can be some kind of cryptic and I would like to learn while solving daily occurrences of different problems I would like you to give a brief explanation of the resulting command itself.
My first approach was to let vim
run a recorded sequence but this is running for 3h now and not even close to the end - even if it would at some point in time solve the problem I would like to know a better and more efficient way.
Requested example:
['string_string': <asdffds.1j2_3>, 'abd_dfA': 212, 'kajaj': <asdffdsa>, 'string_string': <fdjjdjd.asjsk2222>, 'jsjsjsj': 32.23],
['string_string': <asdffds.1j2_3>, 'abd_dfA': 212, 'kajaj': <asdffdsa>, 'string_string': <fdjjdjd.asjsk2222>, 'jsjsjsj': 32.23]
Result:
[ 'abd_dfA': 212, 'kajaj': <asdffdsa>, 'jsjsjsj': 32.23],
[ 'abd_dfA': 212, 'kajaj': <asdffdsa>, 'jsjsjsj': 32.23]
string_string
entry is the last element of such an[ ... ]
array? In that case it would not have the "next,
" as delimiting character.