我正在结合 sox
和 lame
来生成一个新的音乐文件,但是为了使用管道在一行中完成所有操作,似乎有必要“标记”带有 -
字符的输出和输入边界。我继承了这段代码,所以让我展示一下。
sox $DIRNAME/$BASENAME -e signed-integer -r 8000 -c 2 -t wav - trim $POSITIONS | lame -v -V4 --resample 8 - $DIRNAME/${NOEXT}.mp3
wav
和trim
之间的-
为输出文件,-之间的
和 -
-resample 8$DIRNAME/${NOEXT}.mp3
是输入文件。
我正在尝试查找有关此的更多信息,例如是否可以使用任何字符,或者 -
是否以这种方式特殊。这叫什么,它的工作原理是什么?
最佳答案
许多 Unix 命令行实用程序使用“-”作为简写表示“不要在这里使用真实文件,而是使用标准输入(或标准输出)”。 Sox 是这些程序之一:
这是来自 sox manpage
SoX can be used in simple pipeline operations by using the special filename '-' which, if used in place of an input filename, will cause SoX will read audio data from 'standard input' (stdin), and which, if used in place of the output filename, will cause SoX will send audio data to 'standard output' (stdout). Note that when using this option, the file-type (see -t below) must also be given.
关于bash - Unix 管道和位置参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12666501/