2022-05-12
Bash - File Base Name (Without Extension)
file base name (without extension)
i="movie.mp4"
echo ${basename ${i/.mp4}}
Get the current directory name (without full path) in a Bash script
result=${PWD##*/} # to assign to a variable
printf '%s\n' "${PWD##*/}" # to print to stdout
# ...more robust than echo for unusual names
# (consider a directory named -e or -n)
printf '%q\n' "${PWD##*/}" # to print to stdout, quoted for use as shell input
# ...useful to make hidden characters readable.