在单独的行每个字 [英] Each word on a separate line
本文介绍了在单独的行每个字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个像
这是例如:
我想写这使得在这句话每个字被写入到一个单独的行的文件。
I want to write this to a file such that each word in this sentence is written to a separate line.
我怎样才能做到这一点在shell脚本?
How can I do this in shell scripting?
推荐答案
请尝试使用:
string="This is for example"
printf '%s\n' $string > filename.txt
或
string="This is for example"
for word in $string; do
echo "$word"
done > filename.txt
这篇关于在单独的行每个字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文