I'd like to create a tar file of all the files in a directory minus sub-directory's in that directory and place that tar file in one of the sub-directory's. For example, I have several .txt files in /test and also another directory in /test called ArchivedFiles. I'd like to tell the tar command to archive all of the .txt files and place it in /test/ArchivedFiles.
How do I go about doing this?
tar cf test/foo/test.tar -- `find test -maxdepth 1 -name '*.txt' -type f`
I think that should do what you want.
An option which will not work due to the age of your tar command is:
find test -maxdepth 1 -type f -name '*.txt' -print0 | tar -cf test/foo/test.tar --null --files-from -
You are having problems, so you can try the following commands:
tar cf test/foo/test.tar `find test -maxdepth 1 -name '*.txt' -type f`
echo tar cf test/foo/test.tar `find test -maxdepth 1 -name '*.txt' -type f`
tar c f test/foo/test.tar `find test -maxdepth 1 -name '*.txt' -type f`
find test -maxdepth 1 -name '*.txt' -type f
And pastebin the output so that we can see what is happening.
Given that find is very legacy as well, let us try the following:
tar cf test/foo/test.tar test/*.txt