Date: Tue, 23 Dec 2003 09:45:44 +0000 (GMT) From: Jan Grant <Jan.Grant@bristol.ac.uk> To: Zhang Weiwu <weiwuzhang@hotmail.com> Cc: freebsd-questions@freebsd.org Subject: Re: How to count the lines of code in a project? Message-ID: <Pine.GSO.4.58.0312230942240.14217@mail.ilrt.bris.ac.uk> In-Reply-To: <Law11-F62pzhad2VqKw0005fb4d@hotmail.com> References: <Law11-F62pzhad2VqKw0005fb4d@hotmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, 23 Dec 2003, Zhang Weiwu wrote: > > Hello. How to count the number of lines in all *.c file in a directory? > > I can think of this on csh: > > > grep -c "" `find . -name "*.c"` | sed "s/.*:/e=e+/" > /tmp/countlines.py > > And edit the py file, and "e=0" as first line, "print e" as the last > line, and execute the python script. wooo pretty cool for a newbie like > me:) > > So is there a better method? Not bad; but when it comes to basic operations on text files, unix has a surfeit of tools that probably already do what you want. In this case: find . -type f -name \*.c -print0 | xargs -0 wc -l -- jan grant, ILRT, University of Bristol. http://www.ilrt.bris.ac.uk/ Tel +44(0)117 9287088 Fax +44 (0)117 9287112 http://ioctl.org/jan/ (ECHOY GRUNTING) (EERIE WHISPERS) aren't subtitles great?
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.GSO.4.58.0312230942240.14217>