0

Lets say you have this program:

#!/usr/bin/env python
import time
while True: 
    print("True")
    time.sleep(1)

then you run it:

./clock.py | wc -l 

This will never return anything because it waits for the output to finish before giving the word count.

I want something to run instead of wc -l that will display 1..2..3 like a clock almost.

1
  • @VojtechTrefny Im not sure how to do that in this case? tail is for looking at the end of a file but this is not a file, its generated output. tail -n +1 -f clock.py | awk '{printf "\r%lu", NR}' of course does not work
    – BigBoy1337
    Commented Jan 12, 2022 at 20:28

1 Answer 1

1

You can use pv to count and report lines output:

( while :; do echo True; sleep 1; done ) |
    pv --bytes --line-mode >/dev/null

Not the answer you're looking for? Browse other questions tagged .