Linux code statistics

Source: Internet
Author: User

Count the number of file lines (single file ):

WC-l file

For example:

Homer @ Ubuntu :~ /Workspace/Android/Game $WC-l lgameandroid2dactivity. Java
906Lgameandroid2dactivity. Java

Count the number of rows of all files in the directory (all directories ):

Find.-Name *. Java | xargs WC-l

For example:

Homer @ Ubuntu :~ /Workspace/Android $Find.-Name *. Java | xargs WC-l
817./GAME/CORE/lhandler. Java
140./GAME/CORE/lflicker. Java
...
515./GAME/utils/collection/arraymap. Java
162./GAME/utils/collisionutils. Java
178./GAME/utils/numberutils. Java
68753Total

Sort the statistics directory by number of rows (sort by row size ):

Find.-Name *. Java | xargs WC-L | sort-n

Homer @ Ubuntu :~ /Workspace/Android $Find.-Name *. Java | xargs WC-L | sort-n
25./GAME/Action/sprite/colpolicable. Java
26./GAME/CORE/graphics/component/collisionquery. Java
27./GAME/CORE/graphics/filter/imagefilter. Java
28./GAME/lmode. Java
...
1467./GAME/CORE/Geom/path2d. Java
1919./GAME/CORE/graphics/screen. Java
2417./GAME/CORE/graphics/device/lgraphics. Java
3050./GAME/CORE/Geom/affinetransform. Java
 68753Total

Sort the statistics directory by the number of rows (sort by row file name ):

Find.-Name *. Java | xargs WC-L | sort-K2

Homer @ Ubuntu :~ /Workspace/Android $Find.-Name *. Java | xargs WC-L | sort-K2
210./GAME/Action/actioncontrol. Java
116./GAME/Action/actionevent. Java
34./GAME/Action/actionlistener. Java
....
178./GAME/utils/numberutils. Java
342./GAME/utils/recordstoreutils. Java
58./GAME/utils/screenutils. Java
650./GAME/utils/stringutils. Java
68753Total

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.