I want to use grep
command to extract some strings from my data file.
data file format
a=1,b=2,c=3,
a=4,b=5,c=6,
I want the out format
a=1,c=3,
a=4,c=6,
I tried the below command
grep -Po 'a=.*?,|c=.*?,' data
But the output format is incorrect. Please teach me how to do it.
One possibility with
sed
would be as follows.A more generic regex would be as follows.