/bin/rm invalid number of arguments

Getting error in invalid number of arguments when deleting large number of files in directory ?

The error is due to bash shell has a limit of 2621440 to the number of arguments you can pass to a command.  This can be verified by,

[root@hostab ~]# getconf ARG_MAX
2621440

Solution to this problem is to use the find command along with xargs,

cd  to the directory where you want to delete files and run below command

find . -name ‘*’ |xargs rm