Answer the question
In order to leave comments, you need to log in
How to write a regular expression for bash?
Hello.
I understand very badly in the head. Expert help needed.
I run the command avprobe orig/BELS.m4a
and get the following
avprobe version 9.16-6:9.16-0ubuntu0.14.04.1, Copyright (c) 2007-2014 the Libav developers
built on Aug 10 2014 18:16:02 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x2183fe0] max_analyze_duration reached
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from './orig/BELS.m4a':
Metadata:
major_brand : M4A
minor_version : 0
compatible_brands: M4A mp42isom
creation_time : 2009-04-30 21:50:53
track : 5/8
album : Technical Ecstasy
artist : Black Sabbath
title : All Moving Parts (Stand Still)
encoder : iTunes 8.1.1.10
date : 1976
gapless_playback: 1
genre : Музыка
Duration: 00:05:07.38, start: 0.000000, bitrate: 966 kb/s
Stream #0.0(und): Audio: alac, 44100 Hz, stereo, s16p, 956 kb/s
Metadata:
creation_time : 2009-04-30 21:50:53
Stream #0.1: Video: mjpeg, yuvj420p, 300x300, 90k tbn
# avprobe output
Answer the question
In order to leave comments, you need to log in
Regular expressions are not needed.
file="my.mp3"
declare -A MP3
while read line; do
|| continue
IFS='=' read key value <<< "$line"
|| continue
MP3[$key]="$value"
done <\
<(ffprobe 2>&- -show_entries format "$file")
echo "${MP3[TAG:artist]}"
echo "${MP3[TAG:album]}"
echo "${MP3[TAG:title]}"
title=$(avprobe orig/BELS.m4a | sed -rn 's/\s+title\s+:\s+//p')
album=$(avprobe orig/BELS.m4a | sed -rn 's/\s+album\s+:\s+//p')
artist=$(avprobe orig/BELS.m4a | sed -rn 's/\s+artist\s+:\s+//p')
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question