Let’s say that you just unzipped files from a folder and you forgot to specify a destination directory. Now you have your home folder fully of thousands of new files. How do you clean up this mess?
Run this Command
/bin/zipinfo -1 1.0.0-rhel.7-x64.zip | xargs echo rm -rf | sh
What does this Command Do?
- If the file that you just unzipped files from was
1.0.0-rhel.7-x64.zip
which has but 200+ files it would be quite a mess if it was in, lets say, your home directory - first you need to run
/bin/zipinfo -1
to list only the file names in the zip file - pipe that to xargs with takes input or stdin, but we want to echo or print every command it ends up running to stdout.
xargs echo rm -rf
- This command should be thought of as
echo rm -rf {filename}
- Finally, so we can the output of the xargs commands, we pipe that to
sh
which will print that to stdout.| sh