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))