Posts Tagged ‘aix’

Tar and Gzip When Low On Disk Space

Friday, March 12th, 2010

Anyone who knows me knows how I feel about AIX :-P.  One of my peeves is that out of the box, I cannot tar/gzip a directory with the “tar -cvz” command without breaking it up into two separate tar/gzip commands.

Every once in a while, you need to pull a large directory off your server to your local machine or just to copy it to another server.  Sometimes it’s easy just to copy the entire directory uncompressed.  Other times, it just makes sense to tar and gzip the directory so that the file that you are transferring is in a single archive and is compressed as to shorten the transfer time.

The problem with the tar/gzip option is that if you tar then gzip, you need the disk space to do so.

On AIX, here is a solution that will allow you to send what you tar to stdout then gzip it on stdin with no problems with disk space unless the gzip’d tar is still bigger than the diskspace you have available.  This *should* work on other *NIX systems that you cannot throw the gzip switch in the tar command.

tar -cvf - /path/to/dir/you/want/to/tar | gzip > /destination/for/gzip'd/tar.tgz

grep -R Alternative

Thursday, July 2nd, 2009

Ugh…

I have worked with unix/linux now going on my twelfth year.  However, I am still pretty green with AIX as I have only dabbled in it for about two years now.

Although I have grown to enjoy their implementation of logical partitions and other value adds, I have always felt that their OS is old and stuffy.  I was reminded of this recently when I could not perform a recursive grep.  There are a lot of archaic command line switches in this stodgy old OS, not to mention all of the new and cool commands that are missing.

If you find yourself needing to do a grep -R in AIX or in any other *nix OS, here is an alternative command for you using find:

find . -type f | xargs grep -i <string>

For example, if you wanted to find any file that contains the word “voova” in your current working directory and all of the child directories, you would issue:

find . -type f | xargs grep -i voova
  • find . -type f tells the command to locate all files
  • xargs allows for you to execute whatever command follows (in this case it is grep) on each individual file that the find command locates as if you grep’d each file one at a time
  • grep searches for the string where the -i makes the search case insensitive.

Hopefully, this will save you the exercise of RTFM’s

-boogybren