Ubuntu – How to collect all the “txt” and “log” files using find

findscripts

I currently have this script:

find . -iname '*.log' -print0 | xargs -0 tar zcf $file

To collect all the "*.log" files from a given directory. I would like to modify it to include also all the ".txt" files but I don't know how, this should be fairly simple right?

Best Answer

You are on the right way. Try this:

find . \( -iname "*.log" -or -iname "*.txt" \) -print0 | xargs -0 tar zcf $file

Related Question