find command to find files and concatenate them

2019-02-27 11:21发布

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条回答
Rolldiameter
2楼-- · 2019-02-27 11:39

Use cat in -exec and redirect output of find:

find /home/downloaded/ -type f -name '*.gz' -exec cat {} \; > output
查看更多
登录 后发表回答