When I create a .tar file using the tar command, what option do I need to use to add a specific directory hierarchy to the file?

For example:

    |__   MAIN
            |__ SUB1
                   |__ Process.txt

From the top of the manual:

  tar -cf archive.tar foo bar  # Create archive.tar from files foo and bar.

Therefore: tar cf tarfile.tar directory-to-tar

Note: In Unix speak a directory is a file, and many other things also: If it is in a directory, then it has a file-name, and it is a file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.