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##*.}"
Get filename without path
basefilename=$(basename /full/path/to/file.txt)
Get filename without extension
filewoext="${basefilename%.*}"
Get extension of file
fileext="${basefilename##*.}"
Comments
Post a Comment