Linux find files using filename pattern and cat its content

In one of my project, we used to keep commands inside an text file. We will be getting new files every day/week/month and the frequency of getting such file is unpredictable. Every file that our file server receives will be named like file.1,file.2…file.110,file.111,file.112, etc. We bundle all these files on a monthly basis and create executable installer to run these command file one by one. One day,  we were in a need to find list of commands we have received after file version 100. Following Linux command came to us handy,


find . -name "file.10[1-9]" -exec cat {} + > cmdlist.txt
find . -name "file.11[0-9]" -exec cat {} + >> cmdlist.txt

The first command will find all the files between 101 to 109 and append them into a file called cmdlist.txt. The second command will find files from 110 to 119 and append its content one by one into the same file.

What I was not able to find is a continuous pattern (one line command) to find all files from 100 to 157. But I believe aforesaid command might help some one.

Leave a Reply

Your email address will not be published.

WP2Social Auto Publish Powered By : XYZScripts.com