Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

3
  • Does the first method need a dot (.) on the end? I tried it without and got: tar: Cowardly refusing to create an empty archive. When I have the dot, it annoyingly makes the root contain a directory named .. So, close but not perfect. Commented Dec 21, 2015 at 12:58
  • 1
    Further to my previous comment. I solved my issue. $ cd /home/username/dir1/dir2/ && tar -cvf temp.tar selecteddir * worked for me. Using asterisk instead of a dot .. Update: Woops - Although I lost the hidden files. Commented Dec 21, 2015 at 13:10
  • 3
    I know it's an old post but just in case: using a different delimiter may be easier than escaping, e.g. --transform='s:/home/username/dir1/dir2/::g' Commented Jul 27, 2020 at 6:14