본문 바로가기

컴퓨터 사용 팁

Split filename and extension at bash

Split filename and extension at bash

$ FILE="example.tar.gz"
$ echo "${FILE%%.*}"
example
$ echo "${FILE%.*}"
example.tar
$ echo "${FILE#*.}"
tar.gz
$ echo "${FILE##*.}"
gz