find 命令查找文件并连接它们 [英] find command to find files and concatenate them

查看:15
本文介绍了find 命令查找文件并连接它们的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I am trying to find all the files of type *.gz and cat them to total.gz and I think I am quite close on this.

This is the command I am using to list all *.gz

find /home/downloaded/. -maxdepth 3 -type d ( ! -name . ) -exec bash -c "ls -ltr '{}' "

How to modify it so that it will concatenate all of them and write to ~/total.gz

Update: directory structure under downloaded is as follows

/downloaded/wllogs/303/07252014/SysteOut.gz
/downloaded/wllogs/301/07252014/SystemOut_13.gz
/downloaded/wllogs/302/07252014/SystemOut_14.gz

解决方案

Use cat in -exec and redirect output of find:

find /home/downloaded/ -type f -name '*.gz' -exec cat {} ; > output

这篇关于find 命令查找文件并连接它们的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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