Shell, wc : getting progress in real time

On Unix/Linux, “wc” is a very useful tool to count the number of lines in a file or a stream. However, sometimes, the file or stream is so big that it takes minutes or longer to get the final result. In such cases, you might want to get feedback regularly, in real-time, about the progress. Here a simple awk script that will do just that, reporting the number of lines every second, and the finaly the final number of lines:

awk 'BEGIN {T=0} (T!=systime()) { printf "%s %s\n",NR,$0 ; T=systime()} END { print NR}'

(Tested with GNU awk)

Advertisements
This entry was posted in Uncategorized. Bookmark the permalink.

2 Responses to Shell, wc : getting progress in real time

  1. Merten Schumann says:

    Useful! 🙂 Thanx.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s