文件名参数扩展bash

file name parameter expansion bash

我正在尝试查找具有特定扩展名的所有文件并将它们更改为不同的扩展名。这两个扩展都将作为命令行参数放入。我如何在“。”之前设置一个等于文件名的变量?使用参数扩展?我是脚本新手,所以非常感谢任何帮助!

name=${param%.*}

name 设置为 $param 的值,不带扩展名。

来自bash manual

${parameter%word}
${parameter%%word}
The word is expanded to produce a pattern just as in filename expansion. If the pattern matches a trailing portion of the expanded value of parameter, then the result of the expansion is the value of parameter with the shortest matching pattern (the ‘%’ case) or the longest matching pattern (the ‘%%’ case) deleted.