计算终端输出中的行数 [英] count number of lines in terminal output

查看:85
本文介绍了计算终端输出中的行数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在SO上找不到此.我在终端中运行了以下命令:

couldn't find this on SO. I ran the following command in the terminal:

>> grep -Rl "curl" ./

,并显示出现关键字curl的文件列表.我要计算文件数.我能想到的第一种方法是计算终端中输出的行数.我该怎么办?

and this displays the list of files where the keyword curl occurs. I want to count the number of files. First way I can think of, is to count the number of lines in the output that came in the terminal. How can I do that?

推荐答案

将结果放入 wc 使用-l(行数)开关:

Pipe the result to wc using the -l (line count) switch:

grep -Rl "curl" ./ | wc -l

这篇关于计算终端输出中的行数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆