本文介绍了"庆典:坏替代"使用sh文件code时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么

 为我在* .MP4;这样做的ffmpeg -i$ I$ {I / .MP4 / .MP3}; DONE

工作,如果我用它在控制台,但给我一个坏替代的错误,如果我用同样的code在sh文件?

 为我在* .MP4

    ffmpeg的-i$ I$ {I / .MP4 / .MP3}
DONE


解决方案

#!/ bin / sh的的意义

这是因为你使用#!/ bin / sh的在脚本中,作为一个修复,你应该将其更改为#!/ bin中/ bash的

 #!/斌/庆典
因为我在* .MP4

    ffmpeg的-i$ I$ {I / .MP4 / .MP3}
DONE

人们使用#!/ bin / sh的时,只用了最大的可移植性一组功能有限(由POSIX标准定义)。 #!/斌/庆典为用户脚本完全罚款。 / bin / sh的通常是符号链接到一个最小的POSIX兼容的外壳或一个标准shell(如bash)的。在后一种情况下的bash运行在兼容模式下,这是在解释:

Suggested changes to your script:

  • It is good that you use quotes ("$i" instead of $i), which supports file names with white space characters.
  • I like that you use advanced parameter expansion. I suggest to use "${i%.mp4}.mp3" (instead of "${i/.mp4/.mp3}"), since ${parameter%word} only substitutes at the end (for example a file named foo.mp4.backup).

这篇关于"庆典:坏替代"使用sh文件code时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-16 02:14
查看更多