Count rows in shell

Source: Internet
Author: User

Today I suddenly wondered how many lines of code I had written recently, and then I used the shell to figure out the most recent code:

?
1 Find/home/chengshuguang/mango-maxdepth 1-name ' *.c '-or-name ' *.cpp '-or-name ' *.h ' | Xargs wc-l

which

    1. -maxdepth 1 means that only the directory is searched down, that is, no recursion. Similarly, 2 indicates a Level 2 directory.

    2. Xargs its role is to convert the argument list to small pieces to pass to other commands to avoid an issue where the argument list is too long.

    3. If you do not want to count empty rows, you can actually do this:

?
1 2 3 Find. -name "*.M"-or-name "*.h" |xargs grep-v "^$" |wc-l grep-v "^$" means to strip empty rows

Count rows in shell

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.