#!/bin/bash
function count_lines() {
local LINE_COUNT=0
local FILE_COUNT=0
for file in $(find -name $1); do
local lines=$(wc -l $file | sed 's/\([0-9]\+\).*/\1/')
LINE_COUNT=$(expr $LINE_COUNT + $lines)
FILE_COUNT=$(expr $FILE_COUNT + 1)
done
echo "Counted [$LINE_COUNT] in [$FILE_COUNT] [$1] files"
}
count_lines $@
11 February, 2008
Simple Line Counter with Bash
A simple bash based line counter could look like this:
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment