I have a situation where I want to copy a specific file "transaction.log" from thousands of directories under linux and build a tar file containing those same specific files.
Example: I have thousands of directories under /user/foo/dirs/
/user/foo/dirs/dir1
/user/foo/dirs/dir2
/user/foo/dirs/dir3
..
..
..
/user/foo/dirs/dir50000
In each directories, there are several files and a transaction.log file. I would like to copy this transaction.log file from all the 50000 directories and store them in a tar file.
Can you please help me if there is a way to do so?
Thanks.
SOLUTION:
Okies, i found the issue, since there were some sympolic links to other disks find was not working well. solution is to use with -follow option with find to follow the symbolic links. thanks. I use the following command
find . -follow -type f -name "transaction.log" | tar --create --files-from - > /foo/Stats_transaction_Object.tar.gz