Each word on a separate line

前端 未结 7 1286
囚心锁ツ
囚心锁ツ 2021-01-11 09:36

I have a sentence like

This is for example

I want to write this to a file such that each word in this sentence is written to a s

7条回答
  •  天涯浪人
    2021-01-11 10:40

    Use the fmt command

    >> echo "This is for example" | fmt -w1 > textfile.txt ; cat textfile.txt
    This
    is
    for
    example
    

    For full description of fmt and its options, check out the related man page.

提交回复
热议问题