I am writing a perl script to tar multiple files (in unix) from a given directory to a given output directory. I do NOT want the file path included in the tar, so I've flagged the -C option. Example:
tar -cvf tar/1.tar -C htmp/source/ 1-1-1.xml
However, I need to do this for a number of target files from the same directory. I've found that if I just specify another -C flag I can do a second file, like:
tar -cvf tar/1.tar -C htmp/source/ 1-1-1.xml -C htmp/source/ 1-1-19.xml
but this seems way too long, considering the number of files in the given directory. I'm wondering if anyone knows of a syntax shortcut to get all the files in this directory, without having to flag -C for each one.
Thanks
---------- Post updated at 12:27 PM ---------- Previous update was at 12:17 PM ----------
Heh... nvm I found the answer. Just looked at man tar:
"If file is `.', archive all files in directory."
RTFM, I guess.
so,
tar -cvf tar/1.tar -C htmp/source/ .
grabs everything.
Cheers