国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 操作系統(tǒng) > 正文

一個用shell寫的統(tǒng)計目錄下統(tǒng)計文件行數(shù)的代碼

2024-06-28 13:25:12
字體:
供稿:網(wǎng)友
一個用shell寫的統(tǒng)計目錄下統(tǒng)計文件行數(shù)的代碼

此代碼是用來回憶當初學的shell腳本,很多知識忘了,寫這個花了我三個小時的時間

#!/bin/ksh

#count *.c file the num of lineg_csum=0g_hsum=0

count(){# echo "$1,count_line" file_name="$1" res_line=`wc -l $file_name | awk '{PRint $1}'` echo $res_line return# find . -name "*.c" | xargs cat | wc -l}

statistics(){ echo "program start running" cur_line=0 echo $1# g_sum=`count $1` if test -f $1

then cur_line=`count $1` if [ "${1##*.}" = "c" ] then g_csum=$(($g_csum+$cur_line)) elif [ "${1##*.}" = "h" ] then g_hsum=$(($g_hsum+$cur_line)) fi echo $cur_line elif [ -d $1 ] then for file in $1/* do statistics $file done fi echo "g_csum" $g_csum echo "g_hsum" $g_hsum}

for file in $1

do statistics $1done

exit 0


發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 汶川县| 岳西县| 长武县| 永仁县| 沈丘县| 邢台县| 延川县| 梅河口市| 梧州市| 镇坪县| 政和县| 宁远县| 大邑县| 理塘县| 昆明市| 蓬溪县| 大安市| 宁武县| 宁陕县| 南平市| 宜君县| 定陶县| 搜索| 唐河县| 通道| 普陀区| 汝阳县| 常德市| 和静县| 沅陵县| 禹城市| 阿坝县| 齐河县| 微山县| 嵊州市| 邯郸市| 蒙城县| 宜宾县| 满城县| 满城县| 龙江县|