grep -o 'rating=[[:digit:]]\+'
Funciona para mim ...
Então, basicamente, eu estou tentando obter a classificação de um programattially mp3, e usando a ferramenta de linha de comando id3v2, eu posso obter a classificação que o meu programa coloca em:
$ id3v2 -R Drake\ -\ Over3.mp3
id3v1 tag info for Drake - Over3.mp3:
Title : Over Artist: Drake
Album : Thank Me Later Year: 2010, Genre: Unknown (255)
Comment: The highly anticipated debut Track: 0
id3v2 tag info for Drake - Over3.mp3:
TPE2 (Band/orchestra/accompaniment): Drake
TIT2 (Title/songname/content description): Over
TPE1 (Lead performer(s)/Soloist(s)): Drake
TALB (Album/Movie/Show title): Thank Me Later
TYER (Year): 2010
TCON (Content type): Rap - Hip-Hop (255)
TPUB (Publisher): Cash money/Universal Motown
POPM (Popularimeter): Windows Media Player 9 Series, counter=0 rating=196COMM (Comments): (MusicMatch_Preference)[eng]: Very Good
COMM (Comments): ()[eng]: The highly anticipated debut from Drake is here! "Thank Me Later" is hotest album in the game.
APIC (Attached picture): ()[, 3]: image/jpg, 38227 bytes
COMM (Comments): (ID3v1 Comment)[XXX]: The highly anticipated debut
TRCK (Track number/Position in set): PUB
Qual eu posso restringir a
$ id3v2 -R Drake\ -\ Over3.mp3 | grep POPM
POPM (Popularimeter): Windows Media Player 9 Series, counter=0 rating=196COMM (Comments): (MusicMatch_Preference)[eng]: Very Good
Não sei como posso obter "rating = ###" dessa string. Meu awk / sed-fu é fraco: (
Você pode evitar usar duas chamadas de grep
usando essa única chamada de sed
:
id3v2 -R Drake\ -\ Over3.mp3 | sed -n '/POPM/s/.*[[:blank:]]\(rating=\)\([[:digit:]]\+\)\([^[:blank:]]*\)[[:blank:]].*//p'
Você pode escolher o que enviar, removendo as referências anteriores. No seu exemplo, as backreferences geram o seguinte:
- rating =
- 196
- COMM Juntos: "rating = 196COMM"
Tags command-line awk