linux - Removing everything but filename extension -


this question has answer here:

let's have string:

x=file.tar.sh 

i know how remove last n-characters. (removing last 3 characters:

${x: -3} 

but doesn't work files different suffix lengths. (len .tar != len .sh)

i tackle removing until last dot. i've tried this:

${x##.} 

this removes longest matching until "." somehow returns full string without removing anything?

try this:

x=file.tar.sh echo ${x##*.} 

this print sh

if want tar.sh, then:

echo ${x#*.} 

here * matches set of characters before occurrence of .


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -