-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.

6
  • 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 but please search their site for similar questions that may already have the answer you're looking for. Mar 28, 2013 at 16:46
  • Alright, I was directed here thinking it was good for admin tasks. I'll look somewhere else.
    – Lethjakman
    Mar 28, 2013 at 16:50
  • If you ask it on the unix site I'll answer it there :) Mar 28, 2013 at 16:51
  • 1
    @DennisKaarsemaker: Why isn't this an admin task ? ( a simple one admitedly).
    – user9517
    Mar 28, 2013 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. Mar 28, 2013 at 16:57

1 Answer 1

2

try the -C switch.

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

tar -zxvf foo.tar.gz -C /home/user/absolute/subdir
1
  • I'm looking for a command that would look more like tar -jcvf ./foo.tar.bz2 ./*
    – Lethjakman
    Apr 3, 2013 at 18:33

Not the answer you're looking for? Browse other questions tagged .