T
T
tukan2018-11-29 04:44:24
bash
tukan, 2018-11-29 04:44:24

How in bash to count the number of lines printed to the screen after executing a command?

for example, after executing the command ls -l
ps, the solution is needed in general, and not specifically for ls -l

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrey Burov, 2018-11-29
@BuriK666

https://linux.die.net/man/1/wc
If you need to display and calculate, then

res=$(ls -l)
echo "$res"
echo $(echo "$res"|wc -l)

B
Boris Syomov, 2018-11-29
@kotomyava

ls -l | tee >(wc -l)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question