在单独的行每​​个字 [英] Each word on a separate line

查看:96
本文介绍了在单独的行每​​个字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个像

这是例如:

我想写这使得在这句话每个字被写入到一个单独的行的文件。

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆