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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

echo \c equivilent in awk? 2

Status
Not open for further replies.

gawker

Programmer
Feb 21, 2002
34
US
I've an awk process that does a number of system queries to build up a line of data and write out to a file. The format of the awk process is:

awk ' { ... } ' >> work-file

Since it takes a long time to gather the data, I'd like to use a process indicator to show that work is progressing so that the user doesn't think the script is stuck.

In a "normal" shell script equivilent, I'd use an echo statement with a "\c" to suppress the new line character and allow me to build up a catipillar line of dots that grows with each pass. Ex: . then .. then ...

Is there a way to do this from within an awk process? I've tried using the system call with the echo command, but this doesn't work probably because it's a call outside of the immediate process.

Thank you.

Gawker
[trooper]

 
Code:
BEGIN {
   # print a counter for every 100 lines processed
   PREGRESSdiv=100
   stderr="cat 1>&2"
}
!( FNR % PROGRESSdiv) { printf("\rProgress->[%d] lines", FNR)  | stderr; }

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Something like this ?
printf "." > "/dev/tty"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Both solutions are great - One gives more control, the other is simpler. I'll have to decide which to use.

Gawker

[2thumbsup]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top