Ever tried to use the “rm *” command on a directory that has thousands of files? If so, you were probably greeted with the error “too many files”. Here’s how to get around this issue by simply deleting 1 file at a time.

cd /directory1

ls -1 > /tmp/output.output

while read i; do echo $i; rm -f $i; done