Hello,
i have found following:
n=${f%.*} # file name without extension
e=${f#*.} # only extension, without dots
f="abc.def.ghi jkl.tar.gz" && echo "${f%.*}_sample.${f#*.}"
result is wrong:
abc.def.ghi jkl.tar_sample.def.ghi jkl.tar.gz
what is good, universal way to get the file name and the extension (tar.gz, tar.xz, tar) even there are dots and spaces in the file name?
GNU bash, version 5.1.0(1)-release
i have found following:
n=${f%.*} # file name without extension
e=${f#*.} # only extension, without dots
f="abc.def.ghi jkl.tar.gz" && echo "${f%.*}_sample.${f#*.}"
result is wrong:
abc.def.ghi jkl.tar_sample.def.ghi jkl.tar.gz
what is good, universal way to get the file name and the extension (tar.gz, tar.xz, tar) even there are dots and spaces in the file name?
GNU bash, version 5.1.0(1)-release