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##*.}"

Comments

Popular posts from this blog

Database, schema, and table sizes in Greenplum

Greenplum update with multiple tables

Show running queries on Postgresql/Greenplum