컴퓨터 사용 팁

Split filename and extension at bash

뭉기 2019. 5. 15. 00:06

Split filename and extension at bash

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