-1

I would like to be able to tar all of my files so that when the are extracted they're in a sub directory I have specified. For example if I have File1 File2 and File3 inside of my current directory I would like to run a tar -jcvf files.tbz2 ./* in a way that when they extract they extract into files/File1 files/File2 files/File3 without having to create that directory.

Lethjakman
  • 101
  • 2
  • Your question is off topic for Serverfault because it doesn't appear to relate to servers/networking or desktop infrastructure in a professional environment. It may be on topic for [Unix.SE](http://unix.stackexchange.com) but please [search](http://unix.stackexchange.com/search) their site for similar questions that may already have the answer you're looking for. – Dennis Kaarsemaker Mar 28 '13 at 16:46
  • Alright, I was directed here thinking it was good for admin tasks. I'll look somewhere else. – Lethjakman Mar 28 '13 at 16:50
  • If you ask it on the unix site I'll answer it there :) – Dennis Kaarsemaker Mar 28 '13 at 16:51
  • 1
    @DennisKaarsemaker: Why isn't this an admin task ? ( a simple one admitedly). – user9517 Mar 28 '13 at 16:52
  • 1
    @Iain to be honest: I was just being polite and would answer on unix. I really think the question should be closed as nonconstructive, as even a cursory read of the manpage (which is minimal research) would have revealed the answer. My impression is that serverfault requires askers to perform this minimal research itself, where on unix.se such beginner questions without own research are better tolerated. – Dennis Kaarsemaker Mar 28 '13 at 16:57
  • I apologize if I wrote that poorly, but that isn't what I asked, this isn't the same question as marked above. I wanted to tar it so that it would automatically extract into an additional directory as if it were tarred inside of that directory originally. I know about -C when extracting. Does that make any more sense? If so I'll edit my question. – Lethjakman Apr 02 '13 at 22:59

1 Answers1

2

try the -C switch.

tar -zxvf foo.tar.gz -C relative/subdir

tar -zxvf foo.tar.gz -C /home/user/absolute/subdir
David Houde
  • 3,200
  • 1
  • 16
  • 19