How to see the no. of directory in Linux?

Asked By 20 points N/A Posted on -
qa-featured

I just started using Linux, but I have one problem now. I don't know how to see the number of directory in Linux.

Is it possible to see how many files are there in a Linux directory.

Thanks in advance.

SHARE
Best Answer by Valbuena jane
Answered By 590495 points N/A #116823

How to see the no. of directory in Linux?

qa-featured

Here is how to count the number of files in a directory or folder in Linux operating system.

The command is:

ls | wc –l

  • The Is (LS in uppercase) lists the files in the current directory or folder.
  • The | (pipe) will give the result to wc.
  • The wc –l (WC –L in uppercase) will count the number of lines.

Enter the command in small letters to avoid any unwanted errors. 

I just showed it in uppercase to make it more visible.

Best Answer
Best Answer
Answered By 5 points N/A #116824

How to see the no. of directory in Linux?

qa-featured

Try ls -l  my/ directory / | wc -l

Replace my/directory with the directory you want to count files in.

ls        : lists the files in the directory.

wc -l :  counts the actual number of lines .

You can also use:

ls -a   : which will show you all the files including the hidden files

ls -s    : Will show you the size of  file as well.

Try ls | xargs wc -l  if your directory has large number of files in them

Related Questions