How do you only tar files in a directory based on a specific file name?
I want to create a tar ball and include only the files in the directory that start with a specific filename. For instance I have apples-x.x.x and oranges-x.x.x, and I only want to tar the files beginning with "apple". How can I do this?
Thanks!
Ummm, I may be overlooking something, but how about
tar cf /path/tarfile appl*
Unless you have directories which are also called ./appl*
, in which case they'll get trawled up, with their contents, that should do it. If the latter pertains, you can stop that with --no-recursion
.
Maybe something like that:
find / -type f -name "apple*" -exec tar -rf archive.tar '{}' \;
Its better than tar cf /path/tarfile appl*
beacause dont archive directory with pattern apple*