un-unzip a file

unzip -l filename.zip |awk '{ if($4 != "Name" && $4 != "----") print $4}'|xargs -t rm -rf {}
Sometimes you unzip a file that has no root folder and it spews files all over the place. This will clean up all of those files by deleting them.
Sample Output
rm -rf {} OLE/ OLE/PPS/ OLE/PPS/File.php OLE/PPS/Root.php OLE/package.xml OLE/OLE.php OLE/PPS.php Spreadsheet/ Spreadsheet/Excel/ Spreadsheet/Excel/Writer.php Spreadsheet/Excel/package.xml Spreadsheet/Excel/Writer/ Spreadsheet/Excel/Writer/Parser.php Spreadsheet/Excel/Writer/Workbook.php Spreadsheet/Excel/Writer/Validator.php Spreadsheet/Excel/Writer/Format.php Spreadsheet/Excel/Writer/Worksheet.php Spreadsheet/Excel/Writer/BIFFwriter.php CSVtoXLS.php example.csv README.txt 

By: hk0i
2011-10-20 18:54:15

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: