Where would I get a good explanation for all the possibities when using the "printf" unix commmand.
what language?
Unix I think. I want to use it with CygWin.
man sprintf.
Do you have any info about how to use this command.
The information you need is in the manpages of your shell.
With recent versions of bash you may try help printf.
Maybe if you gave an example of what you want to do with printf, we can give you an example of how to do it... there are far too many options to just describe them all to you here.
@ Annihilannic
Input Text File as follows
Statistics,: ,Fri ,Sep ,26 ,00:00:01 ,2008
First ,Interrogation
Incoming,= ,243 ,Outgoing,= 243
ThroughPut,= ,24.28,(requests/sec)
Average ,response ,time,= ,2.47,(ms) ,MIN,= ,1.31,(ms) ,MAX,= ,5.11,(ms) ,No. ,measurements,= ,214,
Intermediate ,Interrogation
Incoming,= ,13 ,Outgoing,= ,13
ThroughPut,= ,1.30,(requests/sec)
Average ,response ,time,= ,3.19,(ms) ,MIN,= ,2.44,(ms) ,MAX,= ,4.15,(ms) ,No. ,measurements,= ,13,
Final ,Report
Incoming,= ,158 ,Outgoing,= ,157
ThroughPut,= ,15.69,(requests/sec)
Average ,response ,time,= ,2.34,(ms) ,MIN,= ,1.53,(ms) ,MAX,= ,3.57,(ms) ,No. ,measurements,
I want this result. a CSV file see below
00:00:01,24.28,1.30,15.69
Could you give me UNIX expression to do this please.
awk would be useful for pulling out that information. Try this:
awk -F' *, *' '
# Print a line feed if we hit a new record and it is not the first one
/^Statistics/ && NR>1 { print "" }
# Print the timestamp, with no line feed after it
/^Statistics/ { printf $6 }
# Print a comma followed by the throughput, with no line feed
/^ThroughPut/ { printf ","$3 }
# Print a line feed at the end of the data
END { print "" }
' inputfile > outputfile
@ Annihilannic
Thanks for all your help. I will try this out later on.
@ Annihilannic
Perfect. Tnx again
@ Annihilannic
See printout below. the AWK command does not seem to work for this file. Any ideas. Tnx
Statistics : Fri Nov 28 00:00:04 2008
Total ThroughPut = 46.76 (requests/sec)
First Interrogation
Incoming = 292 Outgoing = 292
ThroughPut = 29.17 (requests/sec)
Average response time = 2.72 (ms) MIN = 0.72 (ms) MAX = 58.04 (ms) No. measurements = 247
Intermediate Interrogation
Incoming = 27 Outgoing = 27
ThroughPut = 2.70 (requests/sec)
Average response time = 3.44 (ms) MIN = 2.44 (ms) MAX = 4.77 (ms) No. measurements = 26
Final Report
Incoming = 149 Outgoing = 149
ThroughPut = 14.89 (requests/sec)
Average response time = 2.38 (ms) MIN = 1.15 (ms) MAX = 4.26 (ms) No. measurements = 139
That's because the input data is in a different format to your original example, which uses commas as field separators.
Just change the -F option to suit the input data.
@ Annihilannic
What should I use instead of "-F" for this type of data.
@ Annihilannic
Solved it. Thanks for the clue.