Skip to content

Instantly share code, notes, and snippets.

@juanino
Last active November 7, 2019 02:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juanino/26536cbfeb3810713c09 to your computer and use it in GitHub Desktop.
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
# 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