Search code examples
kshgnutar

Having trouble with filenames in tar


I'm having trouble dealing with escape characters in filenames reacting with tar. They can't be removed due to the nature of the data I'm moving. No matter how I format my escape character, it seems to pick up .file and \.file as the same thing.

Ex:

file contents

namefile1 contains \.file

namefile2 contains \\.file

Commands and their output as they appear:

tar -cvzf "./exampleout.tar" -C . -T namefile1
\\.file

tar -cvzf "./exampleout.tar" -C . -T namefile2
\\.file

If i try to list either I get this.

tar -tvf ./exampleout.tar
\\.file

Solution

  • I think I have resolved my issue. If you have \ in your filename, even if you pass it in via a file, you must still escape it. Even if it will take just one in some test cases the only way to make it work consistently. If you try to list the contents of your tar file, it will list it as whatever it was within the file but if you restore it restores in its original form if you can manage to find a glob that tar will take.