Texonom
Texonom
/
Engineering
Engineering
/Hardware Engineering/Computer/Operating System/OS Structure/I/O System/Shell/Shell Implementation/Bash/Bash Variable/
Bash File Name
Search

Bash File Name

Creator
Creator
Seonglae Cho
Created
Created
2021 Jul 13 5:46
Editor
Editor
Seonglae Cho
Edited
Edited
2025 Jun 9 15:53
Refs
Refs
 
 
 
 
 
Extract filename and extension in Bash
The accepted answer works well in typical cases, but fails in edge cases, namely: For filenames without extension (called suffix in the remainder of this answer), extension=${filename##*.} returns the input filename rather than an empty string. extension=${filename##*.} does not include the initial ., contrary to convention.Blindly prepending .
Extract filename and extension in Bash
https://stackoverflow.com/questions/965053/extract-filename-and-extension-in-bash#comment26516503_965053
Extract filename and extension in Bash
 
 

Recommendations

Texonom
Texonom
/
Engineering
Engineering
/Hardware Engineering/Computer/Operating System/OS Structure/I/O System/Shell/Shell Implementation/Bash/Bash Variable/
Bash File Name
Copyright Seonglae Cho