Mailinglist Archive: opensuse (686 mails)

< Previous Next >
Re: [opensuse] bash: how to get file extension
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:(

Why?

"${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".

Have a nice day,
Berny
--
To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx
To contact the owner, e-mail: opensuse+owner@xxxxxxxxxxxx

< Previous Next >
Follow Ups