【发布时间】:2021-10-20 23:17:12
【问题描述】:
我在临时目录中有 3 个文件,如下所示:
test1.txt -- It has 4 lines
test2.txt -- It has 5 lines
test3.txt -- It has 6 lines
需要将文件中的行数连同名称一起计算到单独的文件 (LIST.txt) 中,如下所示
'test1.txt','4'
'test2.txt','5'
'test3.txt','6'
代码尝试:
FileDir=/temp/test*.txt
for file in ${FileDir}
do
filename=$(basename $file) & awk 'END {print NR-1}' ${file} >> /temp/LIST.txt
done
这不是给我名字,它只是给我行数。 另外,如何获得由','分隔的这两个命令的输出?
【问题讨论】:
-
嗨,也许
wc -l *命令可能很有趣 -
是的,这可能会有所帮助。