T
T
TerFelix2018-04-20 20:35:38
bash
TerFelix, 2018-04-20 20:35:38

How to display only the lines you need after processing a command in bash?

there is the output of the eyeD3 ~/some.mp3 command like this:

some.mp3 [ 7.15 MB ]
-------------------------------------- ------------------------------
Time: 03:07 MPEG1, Layer III [ 320 kb/s @ 44100 Hz - Joint stereo ]
------------------------------------ ------------------------------
ID3 v2.3:
title: Brontosaurus artist: Topher Mohr and Alex Elena
album: YouTube Audio Library year: None
boo
track: genre: Rock (id 17)

How to get only YouTube Audio Library from this output into a variable?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Tallmange, 2018-04-20
@TerFelix

eyeD3 ~/some.mp3 | grep album | cut -d':' -f2 | sed 's/year//' | sed 's/^ *//;s/ *$//'

S
Saboteur, 2018-04-20
@saboteur_kiev

eyeD3 ~/some.mp3 | grep -Po "album: \K.*(?= year)"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question