UPDATE
Status of the process for the command rm -rf ~/.local/share/Trash/files/ has been set to Very High. Command was initiated at 0745 today and is still running. CPU Time is current 53 seconds at 0955, memory is constant at 52.0 miB. Status goes between Running and Uninteruptible
I opened up nano yesterday to just look at a file and noticed that inside of my home directory I have a very large amount of files in there that can be deleted. They are there because awhile back I accidentally turned my home directory into a git repo. I undid this, but I want to clean up the mess that I could only see when viewing the folder when searching for a file using nano.
I have this same problem in my trash bin where I have so many files in it from bad git repos that I cannot just click on the trash bin and click empty bin all 8 gigs plus the swap get used up and nothing gets deleted.
How can I delete files from the terminal where the files meet a certain pattern? I have tried the following command:
rm -rf ~/.local/share/Trash/Files/*
rm -rf ~/.local/share/Trash/info/*
and I eventually some time later get a message that there are just to many files and it does not delete.
I would like to say delete all files that start or end with some pattern like .quo or whatever they might be. To sum it up:
How do I list all the files so that I can at least start finding some begining or ending patterns to identify those for deletion How do I use that pattern to delete them?
21 Answer
The error you are getting is because you have too many files which means that * in your rm command is expanded to a list that is longer than the limit (ARG_MAX). So, to get around this you have various options:
Give
rmonly some of the files:rm -rf ~/.local/share/Trash/Files/*.quoDelete the directory containing the files, this avoids listing the files altogether:
rm -rf ~/.local/share/Trash/Files/Use
find:find ~/.local/share/Trash/Files/ -deleteor, for non-GNU
find:find ~/.local/share/Trash/Files/ -exec rm {} +Use a shell loop
for file in ~/.local/share/Trash/Files/*; do rm "$file"; done