Bash:查找和连接文件 [英] Bash: find and concatenate files
本文介绍了Bash:查找和连接文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下结构:
/home/
├── DIR1/
│ └── file_ab.csv
├── DIR2/
│ └── file_cd.csv
└── DIR3/
└── file3_ef.csv
其中 file _ **。csv
包含浮点行,每个DIR有不同的浮动。
Where file_**.csv
contains rows of floats, different floats for each DIR.
我想抓取所有文件_ **。csv
文件的内容,并将它们连接起来。
I want to grab the contents of all of the file_**.csv
files and concatenate them.
我发现这个回答这里:
find /home -type f -name '*.csv' -exec cat {} \; > pl_parameters
但我得到一个名为pl_parameters的空文件。为什么文件为空?如何解决此问题?
But I get an empty file called 'pl_parameters'. Why is the file empty? How can I fix this?
推荐答案
find /home/DIR* -name 'file*csv' |xargs cat > output.csv
find / home / DIR * -name'* csv'
为您提供文件绝对路径。
find /home/DIR* -name '*csv'
gives you the files absolute paths.
xargs cat
将迭代文件, cat
文件内容
xargs cat
will iterate the files and cat
print the files content
这篇关于Bash:查找和连接文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文