0

At the moment I'm using 7zip for Linux CLI and I need to uncompress a lot of files but I need to remove the .7z files after successful extraction. 7z CLI only contains an option that 7z can erase the source files after successful compression, but no for extraction.

I know that 7zip, when it extracts without error, 7z give to console message "Everything is Ok", so I was thinking if I got this message, I can erase the .7z without a problem and Make sure that the extraction is correct and do not delete the .7z in case of any error in the extraction.

Can anyone help me write a simple script to verify successful extraction and delete .7z file?

Janez Kuhar
  • 3,705
  • 4
  • 22
  • 45
javier
  • 11
  • 5
  • You could use the exit code: `$?` – Janez Kuhar Jun 25 '21 at 18:41
  • And how can I extract only "Everything is OK" ? – javier Jun 25 '21 at 20:06
  • So, a non zero exit code would mean that everything was not OK. It could be as simple as: [How to check the exit status using an if statement](https://stackoverflow.com/questions/26675681/how-to-check-the-exit-status-using-an-if-statement) – Janez Kuhar Jun 26 '21 at 10:22

0 Answers0