Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

output formatting in awk
I can't figure out how to format the individual output fields of an
array in the following short awk script:

( NR < 8 ) || ( $7 < 6 ) || ( $11 < 0.0 ) {
next
}
s7 && ( $7 != s7 ) {
V[++n] = FILENAME OFS $7 OFS c10 OFS V11 OFS $11
} {
s7 = $7; c10 = $10; V11 = $11
} END {
for ( i = 1; i <= n; i++ ) print V[i]
}

using the printf() function...  The first field is clearly a string,
the others are variously formatted numbers.

z.entropic

Report this thread to moderator Post Follow-up to this message
Old Post
z.entropic
03-31-08 01:21 PM


Re: output formatting in awk

On 3/31/2008 7:40 AM, z.entropic wrote:
> I can't figure out how to format the individual output fields of an
> array in the following short awk script:
>
> ( NR < 8 ) || ( $7 < 6 ) || ( $11 < 0.0 ) {
> next
> }
> s7 && ( $7 != s7 ) {
> V[++n] = FILENAME OFS $7 OFS c10 OFS V11 OFS $11
> } {
> s7 = $7; c10 = $10; V11 = $11
> } END {
> for ( i = 1; i <= n; i++ ) print V[i]
> }
>
> using the printf() function...  The first field is clearly a string,
> the others are variously formatted numbers.

It's not clear what you're asking for. Provide some small sample input and t
he
expected output for that input.

Ed.



Report this thread to moderator Post Follow-up to this message
Old Post
Ed Morton
03-31-08 01:21 PM


Re: output formatting in awk
z.entropic wrote:
> I can't figure out how to format the individual output fields of an
> array in the following short awk script:
>
> ( NR < 8 ) || ( $7 < 6 ) || ( $11 < 0.0 ) {
> next
> }
> s7 && ( $7 != s7 ) {
> V[++n] = FILENAME OFS $7 OFS c10 OFS V11 OFS $11

Store them formatted here:

V[++n] = sprintf( ... )

Or store each value individually

V[++n,1] = FILENAME
V[n, 2] = $7
V[n, 3] = c10

...

and format them in END

/Thomas

Report this thread to moderator Post Follow-up to this message
Old Post
Thomas Weidenfeller
04-01-08 12:40 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

AWK archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 03:53 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.