-1

I want a command(named rtwc) that acts like wc -c. it reads an input stream(stdin) and writes the number of bytes read after 1 second then update the number every one second. In fact it shows the progress of reading.

This command is useful in a number of situations like performance testing

One can test the command with:

cat /dev/random | rtwc
John Kugelman
  • 349,597
  • 67
  • 533
  • 578
gopy
  • 328
  • 1
  • 9
  • Welcome to SO. Stack Overflow is a question and answer site for professional and enthusiast programmers. The goal is that you add some code of your own to your question to show at least the research effort you made to solve this yourself. – Cyrus Nov 18 '18 at 13:51
  • 1
    Perhaps `watch` is the right way to tackle this? – JNevill Nov 18 '18 at 13:53
  • Go ahead. What's stopping you? – n. m. could be an AI Nov 18 '18 at 13:55
  • This is just a set of requirements. What is your actual question? Someone who wanted to help you would have no idea what part of writing this program you're having trouble with. – Kenster Nov 18 '18 at 14:02
  • Any hint to do it elegantly. also I wonder if there is an existing tool that helps me. – gopy Nov 18 '18 at 14:12

1 Answers1

1

On many Linux systems you can use cpipe, like in

cat /dev/urandom |cpipe -vr >/dev/null

You man need to install it.

Harald
  • 4,575
  • 5
  • 33
  • 72
  • Thanks, cpipe works and is interesting, but I want a solution that writes the output in one line and replaces the output every one second. – gopy Nov 18 '18 at 14:03