Article 5RD40 how to apply grep using a variable?

how to apply grep using a variable?

by
babag
from LinuxQuestions.org on (#5RD40)
i'm trying to use sox to probe some mp3/wav sound files, looking for output something like this:Code:00_Filename.mp3

Peak Level (dB) -3.80
RMS Level (dB) -19.74
Noise Floor (dB) -75.00
Length (seconds) 15.256(the output is a little different in my example above as i also pipe through sed to make the text more understandable. the mp3/wav extension is always the last thing in a line. )

this line works for mp3 files:Code:grep -E 'Pk lev dB|RMS lev dB|RMS Tr dB|Length s|^-|mp3$|^$'since i'm working with both mp3 as well as wav files, though, i want to change the "mp3" call in grep to be a variable so that i can assign it as either "mp3" or "wav":Code:if blah blah blah
filetype="mp3"
else
filetype="wav"
fii guess i need to change the grep call Code:|mp3$|to something likeCode:|$filetype$|i haven't gotten anything to work. i've tried about a million combinations and no luck yet.

can someone show me what to change?

thanks,
babaglatest?d=yIl2AUoC8zA latest?i=nWh-709NMtk:cZGmI2M6zr8:F7zBnMy latest?i=nWh-709NMtk:cZGmI2M6zr8:V_sGLiP latest?d=qj6IDK7rITs latest?i=nWh-709NMtk:cZGmI2M6zr8:gIN9vFwnWh-709NMtk
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments