'kshell'에 해당되는 글 1건

  1. 2009.11.10 counting all file's lines in kshell
((totalSum=0))
((iCount=0))
for fileName in `ls *.txt`
do
  if [ ! -e "$fileName" ]
  then
    echo "$fileName is not exists"
    continue
  fi

  strLineCount=$(wc -l ${fileName} | awk '{print $1}')
  #strLineCount=$(cat $fileName | wc -l)
  echo "$fileName [$strLineCount]"

  ((totalSum=totalSum+strLineCount))
done

echo $totalSum
Posted by stekilove
,