But this will give the directories occupying maximum space. What my command is intended is to get the directories containing maximum number of files (size may be of smaller but count wise they will be high)
Excuse me. You need a simple program "filecount". Something like:
#!/bin/sh
echo $(ls $1 | wc -l) $1
Put this in file, name it "filecount", chmod +x filecount, put this command in your path (for example in $HOME/bin, and add $HOME/bin to PATH), then your find command should work.
Thanks Yazu and itkamraj.
I missed the executable filecount. I was under the impression that filecount is a UNIX command. Found out the missing filecount script and now the command works fine.