Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Bash 将文件的每一行作为参数传递给命令?_Bash_Shell - Fatal编程技术网

Bash 将文件的每一行作为参数传递给命令?

Bash 将文件的每一行作为参数传递给命令?,bash,shell,Bash,Shell,file.txt的内容如下: arg1 sometext arg2 othertext arg3 more and more text 等等。我希望将file.txt的每一行作为参数传递给命令,即: command "arg1 sometext" "arg2 othertext" "arg3 more and more text" ... 请注意,file.txt的每一行都可以包含空格。所以在file.txt中分隔不同参数的是换行符。我该怎么做 xargs -d '\n' -a file.t

file.txt
的内容如下:

arg1 sometext
arg2 othertext
arg3 more and more text
等等。我希望将
file.txt的每一行作为参数传递给
命令,即:

command "arg1 sometext" "arg2 othertext" "arg3 more and more text" ...
请注意,
file.txt
的每一行都可以包含空格。所以在
file.txt
中分隔不同参数的是换行符。我该怎么做

xargs -d '\n' -a file.txt command

(IFS=$'\n';命令$(
BufferedReader
?这是从哪里来的?
cat file.txt | tr'\n'\0'| xargs-0命令
(IFS=$'\n'; command $(< file.txt))