Archive for the ‘Linux’ Category

How to count inode via ssh

Posted by Ivan Guan under Linux

If your provider allows you to ssh to your account, then once you are connected, all you have to do is type the following:

find . -printf “%i\n” | sort -u | wc -l

For more options you can visit http://www.olivetalks.com

How to count files in Linux

Posted by Ivan Guan under Linux

To determine how many files there are in the current directory, put in

ls -1 | wc -l.

This uses wc to do a count of the number of lines (-l) in the output of ls -1. It doesn’t count dotfiles, but seems it will count the directory ./

To include subdirectory files, you can use ls -R | wc -l

To ignore directory ./ you can use find . -type f | wc -l

If you want to count only files and NOT include symbolic links (just an example of what else you could do), you could use ls -l | grep -v ^l | wc -l (that’s an “L” not a “1″ this time, we want a “long” listing here). grep checks for any line beginning with “l” (indicating a link), and discards that line (-v).