bash - Unix 管道和位置参数

标签 bash unix pipe

我正在结合 soxlame 来生成一个新的音乐文件,但是为了使用管道在一行中完成所有操作,似乎有必要“标记”带有 - 字符的输出和输入边界。我继承了这段代码,所以让我展示一下。

sox $DIRNAME/$BASENAME -e signed-integer -r 8000 -c 2 -t wav - trim $POSITIONS | lame -v -V4 --resample 8 - $DIRNAME/${NOEXT}.mp3

wavtrim之间的-为输出文件,-之间的- -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/

相关文章:

windows - 在 BASH windows 上默认设置一个目录

linux - 需要修改我的排序管道,使其成为直通(如猫)

linux - Cron 语法 - 加号/减号

c - 一个一个从子进程中读取数据

c - 当数据到达时从 FIFO 读取数据 (linux)

无法从C 中的管道中执行读取?

linux - 如何删除字符串开始前和结束后的空格

linux - 如何使用文件名中的通配符从chown递归中排除文件?

c++ - 模板的符号表条目

c - mkstemp 和硬盘压力