我有一个 TSV 文件,如下所示:
input.tsv
Apple Give me an iPad.
Apple I love MacBookPro!
Google Buy the Nexus.
Google Chromebooks are easy to use.
Microsoft Surface is awesome.
第一列是一个单词,第二列是一个句子。我只希望我的输出看起来像
apple.txt
Give me an iPad.
I love the MacBook Pro!
google.txt
Buy the Nexus.
Chromebooks are easy to use.
这是我的脚本:
while read -r company sentence
do
for line in $sentence
do
printf "$line\n" >> $company.txt
done
done < input.tsv
但是输出是每行标记一个单词,例如:
apple.txt
Give
me
an
iPad
我不知道怎么了!!!任何人都可以帮忙吗?