gpt4 book ai didi

linux - 将文本行通过管道传输到 linux 命令中

转载 作者:太空宇宙 更新时间:2023-11-04 09:36:22 30 4
gpt4 key购买 nike

假设我有一个包含数百行内容的文件,例如:

content.txt 包含格式为

的行
element1\n
element2\n
element3\n
...

在 linux 中使用命令行是否可以运行 linux 程序,文件中的每个元素减去 \n 作为参数

例如:

$ linuxCommand element1
$ linuxCommand element2
$ linuxCommand element3
$ linuxCommand ...

最佳答案

是的,使用xargs:

xargs -l linuxCommand <content.txt

-l 命令行选项将每次调用 linuxCommand 的参数数量限制为一个。

关于linux - 将文本行通过管道传输到 linux 命令中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26109850/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com