Bash/remove extension

From Attie's Wiki
Revision as of 19:08, 6 September 2012 by Attie (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
function remove_extension {
	cat - | rev | cut -d . -f 2- | rev
}
 
echo "mytestfile.tgz" | remove_extension

Without 'rev'

function remove_extension {
	cat - | sed -re 's/\./\n/g' | awk 'BEGIN{c=0;l=""}{if(c>=2)printf".";printf"%s",l;l=$1;c++;}'
}
Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox