remove files in a directory with large number of files in Linux

When removing files in Linux using:

rm *

Sometimes it give the following error:

bash: /bin/rm: Argument list too long
When the number of files is hugh.

To fix this, we can use xargs:

ls | xargs rm

or

ls *.htm | xargs rm
that will remove all files with extesion .htm