linux – Bash 19个字符没有任何理由消失
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了linux – Bash 19个字符没有任何理由消失,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1457字,纯文字阅读大概需要3分钟。
内容图文
![linux – Bash 19个字符没有任何理由消失](/upload/InfoBanner/zyjiaocheng/961/a1dde58fcd3343038a0ba7ddfdfe7ab6.jpg)
我试图制作一个批处理脚本来压缩我的音频文件,我面临一个非常奇怪的问题.
这是我的代码:
#!/bin/bash
qscale=$1
input=$2
output=$3
inputSize=$((${#input}+1))
find "$input" -type f -name "*.flac" -print0 | while read -d $'\0' a
do
path=${a:inputSize}
echo "Working on $path"
# ffmpeg -i "$a" -qscale:a $qscale "$output/${path[@]/%flac/mp3}" &>/dev/null
done
这是一个结果示例:
Working on 09 - Groove #2 (instrumental studio outtake).flac
Working on 07 - Blues for Allah Sand Castles and Glass Camels Unusual Occurrences in the Desert.flac
Working on 12 - Proto 18 Proper (instrumental studio outtake).flac
Working on 04 - The Music Never Stopped.flac
Working on 13 - Hollywood Cantana (studio outtake).flac
...
如果我取消注释ffmpeg行,这是同一文件夹的结果:
Working on 09 - Groove #2 (instrumental studio outtake).flac
Working on h Sand Castles and Glass Camels Unusual Occurrences in the Desert.flac
Working on 12 - Proto 18 Proper (instrumental studio outtake).flac
Working on r Stopped.flac
Working on 13 - Hollywood Cantana (studio outtake).flac
...
两个文件中的一个文件错过了第19个第一个字符!而且我不知道为什么.
解决方法:
取消注释ffmpeg行并在其上运行shellcheck报告:
Line 12:
ffmpeg -i "$a" -qscale:a $qscale "$output/${path[@]/%flac/mp3}" &>/dev/null
^-- SC2095: Add < /dev/null to prevent ffmpeg from swallowing stdin.
再试一次
ffmpeg -i "$a" -qscale:a $qscale "$output/${path[@]/%flac/mp3}" &>/dev/null < /dev/null
ffmpeg,以及ssh和mplayer,因读取循环时窃取stdin而臭名昭着.
内容总结
以上是互联网集市为您收集整理的linux – Bash 19个字符没有任何理由消失全部内容,希望文章能够帮你解决linux – Bash 19个字符没有任何理由消失所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。