0

I use

sudo tar xvzf forwarder.tar -C /opt/

on Linux and this works perfectly then I proceed with a

. /splunk start

to install a forwarder file.

While in AIX, its forwarder is in .gz format and I tried using

gzip -d filename.gz

And it just decompresses the gz file. Tried also using

sudo tar -xvf -C "/directory/path/" "/home/forwarder.gz"

and its not working too. Tried using .tar also on the command above but to no avail, got no result. How to install on AIX?

  • "not working" is not a diagnose. If you will not provide any more details about "what is not working", you will probably not get any better answer. – Jakuje Nov 17 '15 at 17:14
  • You are so close. Why didn't you try gzip -d followed by tar? – Jeff Schaller Nov 18 '15 at 1:30
  • @Jakuje the sudo tar -xvf -C "/directory/path" "/home/forwarder.gz" command that I used was giving an error that goes like tar: -C: directory or file path not found. Can't post the exact error today but will post it by Friday. Can't test it today because I don't have an access to the server now and and Im basically googling unix commands on AIX but can't make it work as I've said. – lloydknight Nov 18 '15 at 8:31
  • @JeffSchaller followed by tar like? Can you please explain it further? – lloydknight Nov 18 '15 at 8:34
  • @Lloyd: tar is pretty picky about the order of the options and arguments, it always expects after -f option the filename, hence it failed in your example above as you put "-C" there. And for your understanding, on linux tar is usually linked to commonly used (de-)compressors like gzip, bzip2, lzma, xz etc.pp. But originally tar itself is only a simple archiver without compression support. The AIX tar is one without integrated support for external (de-)compressors, so you need to do things manually one after the other, first gunzip and then tar, like meuh or Jeff described already. – doktor5000 Nov 20 '15 at 13:26
2

Though we cannot be sure of what your file contains, as @JeffSchaller suggested, try piping the output of gzip into tar as follows:

gzip -d <filename.gz | 
sudo tar -xvf - -C "/directory/path/"

If this doesnt provide your wanted file, then use the file command on the data to see what type it is. Eg: file filename.gz, and if it is a compressed file then gzip -d <filename.gz | file -.

  • One could use gzip -d <filename.gz | tar -tvf - to see what the tarball contains. It should also be mentioned that sudo is not contained in a default installation, so it should be omitted in my opinion and a hint about necessary root permissions added instead :) – doktor5000 Nov 20 '15 at 13:29
1

Actually, the correct gzip flags are "-dc" as the -c writes to stdout and then the pipe can process it the rest of the way. I frequently use:

gzip -dc something.tar.gz | tar -xf -

to unpack an a gzipped archive. And for bz2, xz, etc.. the commands are similiar:

bzip2 -dc something.tar.bz2 | tar xf -
xz -dc something.tar.xz | tar xf -

And if you are worried that a .tgz file is not going to be accepted by gzip use:

cat something.tgz | gzip -dc - | tar xf -

p.s. these also ALL work on Linux (where I have tried them at least)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.