Today I wrote a shell script that counts the number of source lines in a directory, as follows:
#!/bin/bash
Find. -Name *. Java > Srcfilespathname
Count = $ (wc-l srcfilespathname) # Record the number of source files
echo "Number of source generation files = $count"
While Read PathName
Todo
Countandpath = $ (wc-l $pathName)
echo $countAndPath >> T1
Done < Srcfilespathname
linesum = 0 # Total Row count
While Read Countandpath
Todo
LineCount = ' echo ' $countAndPath | Awk-f ' ' {print '} ' # take the first field, which is the number of rows
Linesum = ' expr $lineCount + $lineSum '
Done < T1
echo "Total number of source lines = $lineSum"
RM Srcfilespathname
RM T1
Exit 0
Later, the master gave a simpler answer, a line of command is enough:-)
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