Bash/remove extension

From Attie's Wiki
(Difference between revisions)
Jump to: navigation, search
(Created page with "<code lang="bash"> function remove_extension { cat - | rev | cut -d . -f 2- | rev } echo "mytestfile.tgz" | remove_extension </code> === Without 'rev' === <code lang="bash"...")

Revision as of 19:07, 6 September 2012

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