更新时间:2023-02-06 19:15:19
每 BashFAQ#1 ,而边读
循环则是适合该作业的工具:
Per BashFAQ #1, a while read
loop is the appropriate tool for the job:
while read -r first_word second_word rest; do
your_command "$first_word" "$second_word"
done <<<"$var"
请注意 rest
的使用-具有占位符( _
也很常见)意味着第二个之后的单词也不会放置在 second_word中
变量.
Note the use of rest
-- having a placeholder (_
is also common) means that words after the second one are not also placed in the second_word
variable.