Saturday, May 18, 2024
6
rated 0 times [  6] [ 0]  / answers: 1 / hits: 1169  / 2 Years ago, fri, may 6, 2022, 5:40:54

How to count the result? when you write a command and some result appears. any way to
count them. For example If I want how many result I have for applications which have python word .



dpkg -l | grep python

More From » command-line

 Answers
6

In the case of grep, you can simply use the -c option



dpkg -l | grep -c python


From man grep



   -c, --count
Suppress normal output; instead print a count of matching lines
for each input file. With the -v, --invert-match option (see
below), count non-matching lines. (-c is specified by POSIX.)


More generally, you can pipe command output to the wc command e.g.



 dpkg -l | grep python | wc -l

[#25098] Friday, May 6, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ightrushi

Total Points: 129
Total Questions: 125
Total Answers: 127

Location: French Southern and Antarctic Lands
Member since Fri, Jan 6, 2023
1 Year ago
;