Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Possible Duplicate:
How to de-unzip, de-tar -xvf — de-unarchive in a messy folder?

I just extracted a RAR archive that contained a lot of files in the base directory. Assuming that there were no filename collisions, what's the easiest way to remove the files just created? Parsing unrar -l seems troublesome due to filename variety.

share|improve this question

marked as duplicate by Gilles, Tim N, Michael Mrozek Nov 5 '11 at 18:42

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

up vote 1 down vote accepted

Use unrar lb archive.rar to get a list of bare filenames, one per line. As long as none of the filenames contained newlines, this should be trivial to parse:

unrar lb archive.rar | perl -ne 'chomp; -d ? rmdir : unlink'
share|improve this answer
Thanks! Didn't know about lb. – user4518 Nov 5 '11 at 18:34