Tar a pre-created list of files

I wanted to tar up all the JPG files in a specific directory and its children. First I made a list of all the JPGs with find:

find /home/bakers -name '*.jpg' > /tmp/jpegs.txt

Then you use the -T file with tar to tell it to read the list of files from a text file

tar -cvpzf /tmp/jpegs.tar.gz -T /tmp/jpegs.txt

Or put the whole thing together in to one command by making -T read from STDIN by (using a slash)

find /home/bakers -name '*.jpg' | tar -cvpzf /tmp/jpegs.tar.gz -T -
Leave A Reply
All content licensed under the Creative Commons License