How to extract the filename without the extension from a full path?
The usual way to do this in bash is to use parameter expansion. (See the bash man page and search for "Parameter Expansion".)
a=${1%.*}
The %
indicates that everything matching the pattern following (.*
) from the right, using the shortest match possible, is to be deleted from the parameter $1
. In this case, you don't need double-quotes (") around the expression.
If you know the extension, you can use basename
$ basename /home/jsmith/base.wiki .wiki
base