Thursday, April 14, 2016

Get filename without path, filename without extension, extension of filename in Bash

SOURCE

Get filename without path
basefilename=$(basename /full/path/to/file.txt)

Get filename without extension
filewoext="${basefilename%.*}"

Get extension of file
fileext="${basefilename##*.}"

No comments:

Post a Comment