Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display * * etc while processing data thru AWK 1

Status
Not open for further replies.

jgl99

Technical User
Feb 26, 2002
12
0
0
US
How do I display * * * etc (loop) while awk is processing a large data file?
 
I assume you mean that you want to print out a progress bar of one * for every n lines. Something like this would work but only if you are not using standard out for your normal pocessing. Otherwise, you would have to figure out how to write to stderr or directly to the screen, which I don't know how to do.
Code:
  if (NR % 1 == 0) {
    printf("*");
    if (++knt == 80) {
      print
      knt = 0;
    }
  }
Hope this helps. CaKiwi
 
Sorry, that should have been
[tt]
if (NR % 1 == 0) {
printf("*");
if (++knt == 80) {
print ""
knt = 0;
}
}
[/tt] CaKiwi
 
Ok it's a little late in the day for me. How about this to print one * for every 100 lines.
[tt]
if (NR % 100 == 0) {
printf("*");
if (++knt == 80) {
print ""
knt = 0;
}
} CaKiwi
 
Hi,

You can write to stderr with the syntax :

printf "*" | "cat 2>&1"

If you use gawk :

printf "*" > "/dev/stderr" Jean Pierre.
 
Thanks aigles, that will come in handy someday. CaKiwi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top