Tar command to extract file into another directory

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kinzy
    New Member
    • Apr 2009
    • 23

    Tar command to extract file into another directory

    I want to extract file into another directory using Tar command i used the following but it didn't work
    Code:
    tar xvf dir.tar -C /export/home/kinzy
    i want to know how can i do this on solaris 10.
  • Nepomuk
    Recognized Expert Specialist
    • Aug 2007
    • 3111

    #2
    How exactly didn't it work? Were the contents unpacked to the current directory? Did you get an error message?

    Comment

    • kinzy
      New Member
      • Apr 2009
      • 23

      #3
      it just give me 2 files not extracted
      if i want to extract on different place i have to change the current directory to the place i want to extract on it

      Comment

      • Nepomuk
        Recognized Expert Specialist
        • Aug 2007
        • 3111

        #4
        Wait, so the command
        Code:
        tar xvf dir.tar
        will extract the files in the same directory but if you add the target directory as you do in the initial post, it doesn't extract?

        Comment

        • kinzy
          New Member
          • Apr 2009
          • 23

          #5
          the output of your command will extract on the same directory where i create the archive.
          but the first command i wrote it didn't make anything

          Comment

          • Rabbit
            Recognized Expert MVP
            • Jan 2007
            • 12517

            #6
            Doesn't the -C option have to come before the file names?

            Comment

            • kinzy
              New Member
              • Apr 2009
              • 23

              #7
              i tried
              Code:
              tar xvf -C dir.tar /export/home/kinzy
              but it gave me error

              Comment

              • Rabbit
                Recognized Expert MVP
                • Jan 2007
                • 12517

                #8
                The path that you pass to the -C parameter should be before the file name as well.

                Comment

                • kinzy
                  New Member
                  • Apr 2009
                  • 23

                  #9
                  like what?
                  i can't understand

                  Comment

                  • Rabbit
                    Recognized Expert MVP
                    • Jan 2007
                    • 12517

                    #10
                    Try
                    Code:
                    tar xvf -C /export/home/kinzy dir.tar

                    Comment

                    • kinzy
                      New Member
                      • Apr 2009
                      • 23

                      #11
                      Also gave me error
                      error "Tar : -C: NO such file or directory"

                      Comment

                      • Nepomuk
                        Recognized Expert Specialist
                        • Aug 2007
                        • 3111

                        #12
                        Damn, of course it won't work... the f option means, that the archive will be the next argument. Here, the following command should work:
                        Code:
                        tar xvC /export/home/kinzy -f dir.tar

                        Comment

                        • kinzy
                          New Member
                          • Apr 2009
                          • 23

                          #13
                          Also gave error
                          tar: C : unknown function modifier

                          Comment

                          • Nepomuk
                            Recognized Expert Specialist
                            • Aug 2007
                            • 3111

                            #14
                            *Sigh* OK, you obviously have a different version of tar than I do, as the above command worked for me. Try the following:
                            Code:
                            tar xv -C /export/home/kinzy -f dir.tar

                            Comment

                            • kinzy
                              New Member
                              • Apr 2009
                              • 23

                              #15
                              No progress
                              4 files not extracted

                              Comment

                              Working...