Mailinglist Archive: opensuse (686 mails)

< Previous Next >
Re: [opensuse] bash: how to get file extension
Bernhard Voelker [15.07.2013 12:36]:
On 07/15/2013 12:08 PM, lynn wrote:
It's nice and short but it only works if you know the number of .'s:(


"${v%.*}" strips off everything past and including the last dot, while
"${v%%.*}" strips off everything past and including the first dot.

Likewise, "${v#*.}" returns everything past the first dot, and
"${v##*.}" gives everything past the last dot.

So in your case - as you want the file extension - the best
bet is "${video_id##*.}" which will return "mp4".

Yes, it should - but in <1373879139.4191.8.camel@xxxxxxxxxxxxx> he wrote
that this does not work for him. So I looked for a far more complicated way.

Just my 2ยข, Werner


To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx
To contact the owner, e-mail: opensuse+owner@xxxxxxxxxxxx

< Previous Next >