[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: sed e estensioni file



> dato il nome di un file "test.txt", vorrei prendere solo l'estensione,
> cioè txt. Ecco quello che sono riuscito a partorire:
>
> echo test.txt |sed 's/\.[[:alnum:]]\{1,4\}$/__OK__/I'

$ echo "some.dotted.words.and.an.extention.txt" | sed 's/\(.*\)\.\(.*\)/\2/'
txt

Questo perche' sed applica regexp greedy (cercati cosa vuol dire se
non lo sai :) )...

Ciao

-- 
Sandro Tosi (aka morph, Morpheus, matrixhasu)
My website: http://matrixhasu.altervista.org/



Reply to: