Paul_Jay
asked on
Delete Original TAR Files After UNTAR
I am running this command on HP UNIX. I have 60 tar files that contain multiple files totaling about 2GB of data in each tar file. The following command is working fine to extract the files. The issue is I don't have enough disk space for all the .tar files and the .dat files it contains to exist at the same time. I want to extract data from FILE1.tar to FILE1A.dat, FILE1B.dat and then delete FILE1.tar before moving on to file FILE2.tar. Is there a way to automatically delete the .tar file once the data has been extracted to the .dat file?
for tarfile in *tar; do tar -xvf $tarfile; done
for tarfile in *tar; do tar -xvf $tarfile; done
ASKER
That seems to work! I've seen references to using && before a command to only run if previous command ended successfully. Would that be useful in this case?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
for tarfile in *tar; do tar -xvf $tarfile; rm $tarfile; done