Jun 1, 2009

Untar to a specific location

There was an occasion when I used a generic script to untar an archive for a lot of servers, 16 in total. Since I cannot issue a cd, I proceeded to untarring and the result was a whole lot of right files in the wrong directory.

This tar option is important for one to be able to do the untarring at the correct location. You need not do a cd, just issue:

tar -C


That's it! Just a -C away and you're untarring to the correct directory.