I am trying to migrate data which consists of a lot of separate text files. One step is to delete all lines in the text files, which are not used anymore. The lines are key-value-pairs. I want to delete everything in a file except those lines with certain keys. I do not know the order of the keys inside of the file.
The keys I want to keep are e.g. version, date and number.
I found this question Remove all lines except matching pattern line best practice (sed) and tried the accepted answer. My sed command is
sed '/^(version=.*$)|(date=.*$)|(number=.*$)/!d' file.txt
with a !d after the address to delete all lines NOT matching the pattern.
Example of the regex: https://regex101.com/r/LKfxpP/2
but it keeps deleting all lines in my file. Where is my mistake? I assume I am wrong with my regex, but whats the error here?