I'm trying to write sed expression which will extract matching groups from file.
E.g. I have .cue sheet and I want to extract it's genre tag. It has following format:
$ cat file.cue | grep GENRE REM GENRE "POP"
I've created sed expression to extract this tag and replace quotes around it:
$ sed -e 's/REM[ \t]*GENRE[ \t]*\(.*\)/\1/;s/"\(.*\)"/\1/;q' file.cue POP
My question is why if it's failed to find matching group it will just print first string?
$ sed -e 's/REMerror[ \t]*GENRE[ \t]*\(.*\)/\1/;s/"\(.*\)"/\1/;q' file.cue REM GENRE POP
Example of cue-sheet:
REM GENRE "POP" REM DATE 2012 REM DISCID EC10BD10 REM COMMENT "ExactAudioCopy v0.99pb5" PERFORMER "JAM Project" TITLE "JAM Project BEST COLLECTION IX THE MONSTERS" FILE "LACA-15250.flac" WAVE TRACK 01 AUDIO TITLE "THE MONSTERS" PERFORMER "JAM Project" INDEX 01 00:00:00