I have several hundred PDFs under a directory in UNIX. The names of the PDFs are really long (approx. 60 chars).
When I try to delete all PDFs together using the following command:
rm -f *.pdf
I get the following error:
/bin/rm: cannot execute [Argument list too long]
What is the solution to this error?
Does this error occur for mv
and cp
commands as well? If yes, how to solve for these commands?
I'm surprised there are no
ulimit
answers here. Every time I have this problem I end up here or here. I understand this solution has limitations butulimit -s 65536
seems to often do the trick for me.Try this also If you wanna delete above 30/90 days (+) or else below 30/90(-) days files/folders then you can use the below ex commands
Ex: For 90days excludes above after 90days files/folders deletes, it means 91,92....100 days
Ex: For only latest 30days files that you wanna delete then use the below command (-)
If you wanna giz the files for more than 2 days files
If you wanna see the files/folders only from past one month . Ex:
Above 30days more only then list the files/folders Ex:
Suppose input directory name is input and output directory name is output. Then you can use simple loop to copy all
I have faced a similar problem when there were millions of useless log files created by an application which filled up all inodes. I resorted to "locate", got all the files "located"d into a text file and then removed them one by one. Took a while but did the job!
The reason this occurs is because bash actually expands the asterisk to every matching file, producing a very long command line.
Try this:
Warning: this is a recursive search and will find (and delete) files in subdirectories as well. Tack on
-f
to the rm command only if you are sure you don't want confirmation.You can do the following to make the command non-recursive:
Another option is to use find's
-delete
flag:The rm command has a limitation of files which you can remove simultaneous.
One possibility you can remove them using multiple times the rm command bases on your file patterns, like:
You can also remove them trough find command: