linux-View the number of files __linux

Source: Internet
Author: User
Tags file permissions

Sometimes you need to see how many files are in the folder, so you need to use the following instructions

$ls-L | Grep-c ' ^-'

What does a grep mean? We're man.

$man grep

You will see the following description:

Synopsis
       grep [OPTIONS] pattern [FILE ...]
       grep [OPTIONS] [e-pattern |-f file] [file ...]
DESCRIPTION
       grep  searches  the named  input  files (or standard input if no files are
       named, Or if a single hyphen-minus (-) are given as file name for lines
       containing a match to the given pattern.  By default, grep prints the matching lines.

Is that the white is to print out and in the file to find and pattern the same keyword, and then print out the line, the other options parameters please use the man command to view,-C is not directly printed, but statistics line number, then "^-" this is what meaning it.

Linux common file types are: Ordinary files, directory files, character device files and block device files, symbolic link files, including:
    1 Normal file file permissions The first character is "-"
    2 directory Files file permissions The first character is "D"
    3 File permissions for character device files The first character is "C"; file
    permissions for 4-block device files The first character is the file permissions for the "B"
    5 symbolic Link File The first character is "s"

Then I understand, in fact, is to count the number of ordinary documents BAI, the same can be ~

# Number of statistical catalogs
$ls-l | grep-c ' ^d '

I want to count it recursively. Then change the ls-l to LS-LR on the line ~ ~

(end)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.