unix art
Pages
Home
shell tip: get parts of a filename
# works in bash, zsh and ksh93
~$ f=file.tar.bz2
~$ echo "${f##*.}"
bz2
~$ echo "${f#*.}"
tar.bz2
~$ echo "${f%.*}"
file.tar
~$ echo "${f%%.*}"
file
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment