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 -


Note: Replies will be formatted with PHP Markdown Extra syntax.

Name: Email (Not Required):
 
Logged IP: 3.138.124.28
To prevent spam please submit by clicking the kitten: