Difference between revisions of "Short Notes on Bash"

From PaskvilWiki
Jump to: navigation, search
(Created page with "== Extensions and File Name == <pre>$ fullname='/tmp/file.tar.gz' $ filename=$(basename $fullname) $ echo ${filename##*.} >> gz $ echo ${filename#*.} >> tar.gz $ echo ${filename...")
(No difference)

Revision as of 21:16, 1 June 2012

Extensions and File Name

$ fullname='/tmp/file.tar.gz'
$ filename=$(basename $fullname)
$ echo ${filename##*.}
>> gz
$ echo ${filename#*.}
>> tar.gz
$ echo ${filename%.*}
>> file.tar
$ echo ${filename%%.*}
>> file

For more options and explanations, see Bash - Shell Parameters Expansion.