1

I downloaded this file and when I try to use -C with tar to change the name of the directory it outputs to, I get this error

$ tar -xvf requests.tar -C requests
tar: could not chdir to 'requests'

I don't get this error when extracting files without -C. I tried this in /tmp and ~/Desktop I also tried passing an absolute path.

1 Answer 1

3

man tar tells you the issue

-C directory, --cd directory, --directory directory In c and r mode, this changes the directory before adding the following files. In x mode, change directories after opening the archive but before extracting entries from the archive.

Thus you have to have the directory created before you change into it.

Without the -C tar extracts to the current directory

Thus for file dir/a.txt in the tarred file

With -C requests the file ends up in requests/dir/a.txt

whilst with no argument it ends up in ./dir/a.txt

You must log in to answer this question.