---
title: "SHELL脚本--统计目录文件的行数"
author: "colorfire"
date: "2010-06-12T13:06:18Z"
tags: []
categories: ["操作系统"]
slug: "shell"
draft: false
lastmod: "2010-06-12T13:07:12Z"
id: 690455
url: "https://colorfire.iteye.com/blog/690455"
---

没基础，写的比较2...

```linux

#!/bin/sh
total=0
udr='/ldata/fuse-udr-split/'
logfile='/home/xxxx/total.log'
rm ${logfile}
for dire in `ls ${udr}`
do
diry=${udr}${dire}
echo ${diry}
if [ -d ${diry} ]
then
cd ${diry}
for file in `ls`
do
if [ -f ${file} ]
then
b=`wc -l ${file} | awk -F' ' '{print $1}'`
total=`expr $total + $b`
fi
done
echo "${diry}:${total}"
echo "${diry}:${total}">>${logfile}
fi
done
```