How to “undo” unzip command?

I used “unzip XXX.zip” to extract a zip file, unfortunaly, i make a mistake.

Now i want to delete all the file and directorys generated by “unzip”.
How can I undo it?

Answer

use this:

unzip -l filename |  awk 'BEGIN { OFS="" ; ORS="" } ; { for ( i=4; i<NF; i++ ) print $i " "; print $NF "\n" }' | xargs -I{} rm -v {}

Use this if you are skeptical (will prompt for confirmation)

unzip -l filename |  awk 'BEGIN { OFS="" ; ORS="" } ; { for ( i=4; i<NF; i++ ) print $i " "; print $NF "\n" }' | xargs -I{} rm -iv {} 

Attribution
Source : Link , Question Author : hero2008 , Answer Author : Abhijeet Rastogi

Leave a Comment