10
5
I'm trying to right my first bash script, and at one point a filename is passed to the script as $1
. I need to extract the file name without the extension.
Currently, I'm assuming that all extensions are three letters so I remove the last 4 characters to get the file name:
a="${1:0:-4}"
But I need to be able to work with extensions that have more than three characters, like %~n1
in Windows.
Is there any way to extract the file name without the extension from the arguments?
http://stackoverflow.com/questions/2664740/extract-file-basename-without-path-and-extension-in-bash – sancho.s Reinstate Monica – 2016-03-31T18:33:32.257