如何让猫开始一个新行 [英] How to make cat start a new line

查看:109
本文介绍了如何让猫开始一个新行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有四个文件:

one_file.txt

one_file.txt

abc | def

two_file.txt

two_file.txt

ghi | jkl

three_file.txt

three_file.txt

mno | pqr

four_WORD.txt

four_WORD.txt

xyz| xyz

我想连接所有文件file.txt(即所有除four_WORD.txt)结尾的文件中,以获得:

I want to concatenate all of the files ending with "file.txt" (i.e. all except four_WORD.txt) in order to get:

abc | def
ghi | jkl
mno | pqr

要做到这一点,我运行:

To accomplish this, I run:

猫* file.txt的> full_set.txt

cat *file.txt > full_set.txt

不过,full_set.txt出来的:

However, full_set.txt comes out as:

abc | defmno | pqrghi | jkl

任何想法如何正确有效地做到这一点,使每一个在其自己的行结束了?在现实中,我需要做的上面有很多非常大的文件。预先感谢您的帮助。

Any ideas how to do this correctly and efficiently so that each ends up on its own line? In reality, I need to do the above for a lot of very large files. Thank you in advance for your help.

推荐答案

尝试:

awk 1 *file.txt > full_set.txt

这是低效率的,一个的,但会增加一个额外的 \\ n 如果在每个文件的结尾缺失

This is less efficient that an bare cat but will add an extra \n if missing at the end of each file

这篇关于如何让猫开始一个新行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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