Thursday, 1 October 2009

Get the total number of lines

If you want to know the total number of lines of files in a directory, execute the following line of script in your terminal. You can also save this command in a file and execute.

lines=0; for i in `find . -name “*.php”`; do line=`cat $i | wc -l`; let lines=$lines+$line; done; echo $lines


OR
find . -name “*.php” -print0 | xargs -0 wc -l | tail -n1

No comments:

Post a Comment