Last active
November 7, 2019 02:21
-
-
Save juanino/26536cbfeb3810713c09 to your computer and use it in GitHub Desktop.
do an ls in a huge dir and print out a shell script to remove. better than shell globbing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# when you have millions of files | |
# this is faster than ls if you don't need the other metadata | |
# like mod times or perms | |
from os import listdir | |
files = listdir(".") | |
# here we can output the giant list with some rm commands | |
# then you can pipe it to sh -x to perform the operations you wawnt | |
# or grep out the noise first | |
for file in files: | |
print "rm " + file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment