I'm trying to count the number of lines of output a certain program produces. The problem is, the program takes a long time to run, and I want to display the output to the user. Is there a way to count the number of lines the last command outputted?
I could do program | wc -l
but that wouldn't show the output to the user. So as far as I know, I have to do program; program | wc -l
- but the program takes at least a minute to run, so I don't want to have to do it more than once just to show a line count at the bottom.
EDIT:
- Is there a way of showing the output as it happens (line by line) and then returning a count at the end?
STDOUT_WRITE_COUNT
), or log it to a file/API, at the end of the program. WDYT?