linux中 改文件后缀名,如何在Linux shell脚本中更改文件扩展名?

如果你正在使用bash

${f%%.mp4}

将给出没有.mp4扩展名的文件名.

尝试使用它像这样:

for f in *.mp4; do

ffmpeg -i "$f" -f mp3 -ab 192000 -vn "mp3s/${f%%.mp4}.mp3"

done

…并且不要忘记给出的示例中的do关键字.

说明

bash手册(man bash)声明:

${parameter%word} ${parameter%%word}

Remove matching suffix pattern.

The word is expanded to produce

a pattern just as in pathname expansion. If the pattern matches

a trailing portion of the expanded value of parameter, then the

result of the expansion is the expanded value of parameter with

the shortest matching pattern (the %'' case) or the longest

matching pattern (the%%” case) deleted. If parameter is @

or *, the pattern removal operation is applied to each positional parameter in turn, and the expansion is the resultant

list. If parameter is an array variable subscripted with @ or

*, the pattern removal operation is applied to each member of

the array in turn, and the expansion is the resultant list.

这只是您可以对shell变量执行的许多字符串操作之一.它们都以参数扩展名称命名.

这也是bash手册中给出的章节标签.因此man bash / paramter exp应该快速带你到那里.`

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值