Mailinglist Archive: opensuse (686 mails)

< Previous Next >
Re: [opensuse] bash: how to get file extension
On Mon, 2013-07-15 at 12:36 +0200, Bernhard Voelker wrote:
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?

My fault. The string is created in another shell. It works fine on the
ground, exactly as in your example. I had to combine the scripts.

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

Works perfectly. Elegant.
Thanks


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

< Previous Next >