find command to find files and concatenate them

孤街醉人 提交于 2019-12-04 04:00:15

问题


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

回答1:


Use cat in -exec and redirect output of find:

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



回答2:


Use echo in -exec and redirect the output:

find /home/downloaded/ -name "*.gz" -exec echo {} \; > output 


来源:https://stackoverflow.com/questions/25083335/find-command-to-find-files-and-concatenate-them

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!