I have a filename which ends with .zip
and I wanted just the filename without zip. Here I found a trick in bash.
$f="05 - Means-End Analysis Videos.zip"
$echo "${f%*.zip}"
05 - Means-End Analysis Videos
What is happening here? How come %*.zip
is removing my extension?
*
is superfluous (always matches nothing when used after single%
). – Mazard%
character in bash is if a program such asvim
is suspended withctrl-z
, then the%vim
command resumes it, likefg
. – Steeplejack*
does not make much sense. The snippet"${f%*.zip}"
means keep the content off
, but remove the last occurrence of.zip
. * ~ * ~ * So in"05 - Means-End Analysis Videos.zip"
simply cut out.zip
to get"05 - Means-End Analysis Videos"
. – Enhanced