13 Replies - 22716 Views - Last Post: 14 April 2012 - 02:38 AM

#1 diek  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 53
  • Joined: 06-November 11

Extract and Uncompress tar.Z file, One Command (Solaris)

Posted 09 April 2012 - 07:03 PM

I have been searching for an answer on this one for a while, the examples I have found do not work.
The file was created as follows:
1. tar cvf home.tar *
2. compress -v home.tar

Resulting in home.tar.Z

I have tried:

tar -zxf home.tar.Z
tar -zxvf home.tar.Z

I have read through Solaris 10 System Essentials. And so far all the web sites I have visited have this one of the two variations of the syntax, mostly the latter. Yet TAR returns a usage error
"tar: z: unknown function modifier
Usage: tar {c|r|t|u|x}[BDeEFhilmnopPqTvw@[0-7]][bfk][X...] [blocksize] [t arfile] [size] [exclude-file...] {file | -I include-file | -C directory f ile}..."

I am pretty new to Solaris and the unix environment. I am getting better but I need some help to extract and decompress this file with one command.

Thank you.

Is This A Good Question/Topic? 0
  • +

Replies To: Extract and Uncompress tar.Z file, One Command (Solaris)

#2 no2pencil  Icon User is offline

  • Admiral Fancy Pants
  • member icon

Reputation: 5388
  • View blog
  • Posts: 27,383
  • Joined: 10-May 07

Re: Extract and Uncompress tar.Z file, One Command (Solaris)

Posted 09 April 2012 - 07:07 PM

I've not seen that 'compress' issued before. Most often people download what is called a tar-ball, & it's a tar file that has been compressed with gzip. Issuing the dash z option to tar says to unzip the file first, & then proceed with the untar. The dash z works with gzip compressed files. Also they are named with a .tgz file extension.

I can't say one way or another with absolute certainty. But I would think that what you are trying to do is not possible by using a file from the output of compress.
Was This Post Helpful? 1
  • +
  • -

#3 Lemur  Icon User is offline

  • Pragmatism over Dogma
  • member icon


Reputation: 1383
  • View blog
  • Posts: 3,514
  • Joined: 28-November 09

Re: Extract and Uncompress tar.Z file, One Command (Solaris)

Posted 09 April 2012 - 07:11 PM

You can use uncompress but I would rather use gzip than compress considering it's a tad more universal and that'll give you the extra options for a one-liner.

The file would be file.tar.gz

create:
tar -czvf archivename.tar.gz filetocompress

uncompress:
tar -zxvf archivename.tar.gz

This post has been edited by Lemur: 09 April 2012 - 07:14 PM

Was This Post Helpful? 1
  • +
  • -

#4 diek  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 53
  • Joined: 06-November 11

Re: Extract and Uncompress tar.Z file, One Command (Solaris)

Posted 09 April 2012 - 07:24 PM

I appreciate the fast response. I only know that this is possible because this is homework, this is the last step. I was able to work through 1-7, but I am stuck on this one. The Compress command came from Linux and Unix Compress Cmd, there is of course an uncompress cmd. My peers used the Compress cmd.

So as I now understand unlike Windows, linux, unix and solaris, the concept of extract and uncompress are two seperate, but related, concepts/commands??
Was This Post Helpful? 0
  • +
  • -

#5 no2pencil  Icon User is offline

  • Admiral Fancy Pants
  • member icon

Reputation: 5388
  • View blog
  • Posts: 27,383
  • Joined: 10-May 07

Re: Extract and Uncompress tar.Z file, One Command (Solaris)

Posted 09 April 2012 - 07:25 PM

Maybe the assignment is to build a script? Thus you pass it two parameters, one indicated compress or uncompress, & the 2nd indicating the file name?
Was This Post Helpful? 0
  • +
  • -

#6 diek  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 53
  • Joined: 06-November 11

Re: Extract and Uncompress tar.Z file, One Command (Solaris)

Posted 09 April 2012 - 07:26 PM

And to be clear the file types were dictated to me, eg. home.tar.Z.
Was This Post Helpful? 0
  • +
  • -

#7 diek  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 53
  • Joined: 06-November 11

Re: Extract and Uncompress tar.Z file, One Command (Solaris)

Posted 09 April 2012 - 07:34 PM

It is an overall script, but it is just to capture all the work in one file. Can I use the pipe character to combine the uncompress and tar? I think Catherine (my teacher) idea of one command, has included the '|' in the past.
Was This Post Helpful? 0
  • +
  • -

#8 diek  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 53
  • Joined: 06-November 11

Re: Extract and Uncompress tar.Z file, One Command (Solaris)

Posted 09 April 2012 - 08:48 PM

And please note, I am continuing the search on my own, in conjuction with the forum. I appreciate the help thus far.
Was This Post Helpful? 0
  • +
  • -

#9 diek  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 53
  • Joined: 06-November 11

Re: Extract and Uncompress tar.Z file, One Command (Solaris)

Posted 10 April 2012 - 09:59 AM

uncompress -v home.tar.Z | tar -xvf home.tar
Did the job, I agree with you guys compress is not the way to go.
Was This Post Helpful? 0
  • +
  • -

#10 baavgai  Icon User is online

  • Dreaming Coder
  • member icon

Reputation: 5929
  • View blog
  • Posts: 12,851
  • Joined: 16-October 07

Re: Extract and Uncompress tar.Z file, One Command (Solaris)

Posted 10 April 2012 - 11:18 AM

Haven't seem compress is a long time...

Note the uncompress -v foo.tar.Z | tar -xvf foo.tar probably isn't doing what you want. There's no real piping going on and tar wasn't told to expect any. If you want to not run command2 unless command1 finishes successfully, use command1 && command2.

You might try:
uncompress -c foo.tar.Z | tar xv -



This should send to uncompress result to stdout and the tar should take it from there. This has the bonus of not messing with the original file.
Was This Post Helpful? 3
  • +
  • -

#11 diek  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 53
  • Joined: 06-November 11

Re: Extract and Uncompress tar.Z file, One Command (Solaris)

Posted 10 April 2012 - 06:29 PM

baavgai, Makes perfect sense, the class linux whiz kid agrees with you that the above cmd is incorrect. That said the teacher did it the way I wrote. She is flexible so I will send this along to her. On a separate but related note, that was the last time I have to open up a Solaris VM. I hate it. I am happy with Mac and linux.
thanks,
diek
Was This Post Helpful? 0
  • +
  • -

#12 Lemur  Icon User is offline

  • Pragmatism over Dogma
  • member icon


Reputation: 1383
  • View blog
  • Posts: 3,514
  • Joined: 28-November 09

Re: Extract and Uncompress tar.Z file, One Command (Solaris)

Posted 10 April 2012 - 09:18 PM

Then you're not using it correctly. Every operating system has its strengths and its weaknesses. A few examples:

Windows is great for convenience and compatibility but horrid with security
Mac is great for an expensive paperweight but horrid to get anything done with
OpenBSD is great for security and reliability but lord help the guy who tries it as a desktop

Solaris tends to be a more stable database server than most given its file systems and close workings with Oracle.
Was This Post Helpful? 0
  • +
  • -

#13 diek  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 53
  • Joined: 06-November 11

Re: Extract and Uncompress tar.Z file, One Command (Solaris)

Posted 10 April 2012 - 10:07 PM

Lemur,
Hate was a strong word, maybe painful learning experience better describes it. I see your point. It is solid and dependable, just not a friendly desktop app. And one term working in it was not really enough.
Was This Post Helpful? 0
  • +
  • -

#14 Lemur  Icon User is offline

  • Pragmatism over Dogma
  • member icon


Reputation: 1383
  • View blog
  • Posts: 3,514
  • Joined: 28-November 09

Re: Extract and Uncompress tar.Z file, One Command (Solaris)

Posted 14 April 2012 - 02:38 AM

Oh trust me, if you try and use most Solaris or OpenBSD type OSs designed for security and reliability on a desktop environment you'll pull out your hair fast. The more security the more rigid the OS. For a server that's great, but for a desktop that can really damper progress to a newer user.

That being said, a high level unix user would have no problems getting OpenBSD to behave quite well as a Desktop OS, but for a learner it would be impossible.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1