从文件中提取的话 [英] Extract words from files

查看:93
本文介绍了从文件中提取的话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎么能提取所有从一个文件的话,在一行上的每一个字?
例如:

test.txt的

 这是我的示例文本

输出:

 

我的
样品
文本


解决方案

tr命令可以做到这一点...

  TR [:空白:]的'\\ n'<的test.txt

这问 TR 程序用一个新行来代替空格。
输出是标准输出,但它可以被重定向到另一文件,的Result.txt:

  TR [:空白:]的'\\ n'< test.txt的>的Result.txt

How can I extract all the words from a file, every word on a single line? Example:

test.txt

This is my sample text

Output:

This
is
my
sample
text

解决方案

The tr command can do this...

tr [:blank:] '\n' < test.txt

This asks the tr program to replace white space with a new line. The output is stdout, but it could be redirected to another file, result.txt:

tr [:blank:] '\n' < test.txt > result.txt

这篇关于从文件中提取的话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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