option to delete .tar file while extracting

Is there an option in tar which deletes the .tar file as soon as it is successfully extracted.

Depends. If you enter tar --help or man tar, is there?

Well, I just skimmed the man page but there is no switch that deletes the tar file after extraction.

But shell scripting would do the job fine, you just have to type a bit more (or create new alias/shell script)

of course it can be done by scripting. However my file system has low disk space and i cannot have both the .tar and the extracted file at the same time.

well why not something like this

say you have a file test.tar.gz and you want to extract content and rm. why not something like

gunzip -c test.tar.gz | tar -xvf -; rm test.tar.gz

would this work for you?

** edit to this post **
now that i think about it, its pretty much the same thing as what bsddaemon just posted :X

As a side note, that one liners can be shorter :slight_smile:

tar -xzf test.tar.gz && rm test.tar.gz

I dont have Solaris with me now, but I believe for bzip2, the switch needed is j