linux – Is it possible to delete a huge number of files in a directory?

Question:

Is there a console solution to the following problem? The folder contains a lot of files like:

xaaaacqjz
xaaaacqka
xaaaacqkb
xaaaacqkc
xaaaacqkd
xaaaacqke
xaaaacqkf
xaaaacqkg

There are so many of them that thunar simply stops responding, in general, I cannot solve the problem in the huyne.

Can I somehow remove them with the rm command? It would be possible to cut out the folder completely, but there I have too much usable material. Help me please!

Answer:

in general, of course, you can delete files with the rm program:

$ rm список файлов

in particular, for example, files in the /путь/к/каталогу that xaaaa* mask:

$ rm /путь/к/каталогу/xaaaa*

but if there are so many files that their full list does not fit into the limitation on the length of the argument list ( $ getconf ARG_MAX will show this limitation – in bytes), then (even in the process of forming the list of arguments) you will receive an error:

bash: / bin / rm: Argument list too long

in this case, you can use the find program:

$ find /путь/к/каталогу -maxdepth 1 -type f -name xaaaa\* -delete
Scroll to Top