Sponsored Content
Full Discussion: awk format layout
Top Forums Shell Programming and Scripting awk format layout Post 302651577 by agama on Tuesday 5th of June 2012 08:29:30 PM
Old 06-05-2012
Nothing but brute force here:

Code:
awk '
    BEGIN { fmt = "%-10s %-10s %-10s %-10s %-10s %-10s %-10s\n";  }
    /Label/ { printf( fmt, $1, $2, $3 " " $4, $5, $6, $7, $8 " " $9 ); next; }

    NF == 10 { printf( fmt, $1, $2, $3 " " $4, $5, $6 " " $7,  $8, $9 " " $10 ); next; }

    NF == 9 && $6 == "mb" {
        printf( fmt, $1, $2, $3 " " $4, " ", $5 " " $6, $7, $8 " " $9 )
        next;
    }

    NF == 9  {
        printf( fmt, $1, $2, $3 " " $4,  $5,  $6 " " $7,  " ",  $8 " " $9 )
        next;
    }

    NF == 8  {
        printf( fmt, $1, $2, $3 " " $4,  " ", $5 " " $6, " ", $7 " "  $8 )
        next;
    }

'  input-file >output-file

This User Gave Thanks to agama For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Output in a particular format using AWK

Hi All, I am trying to check if if column 5 is greater than 90. If greater it will print the term in column 6, else if all are within limit, then it will output "Size is within limit". I can't seem to do that with the below code. The output should only be 1 statement of "Size is within the... (4 Replies)
Discussion started by: Raynon
4 Replies

2. Shell Programming and Scripting

AWK CSV to TXT format, TXT file not in a correct column format

HI guys, I have created a script to read 1 column in a csv file and then place it in text file. However, when i checked out the text file, it is not in a column format... Example: CSV file contains name,age aa,11 bb,22 cc,33 After using awk to get first column TXT file... (1 Reply)
Discussion started by: mdap
1 Replies

3. Shell Programming and Scripting

scripting/awk help : awk sum output is not comming in regular format. Pls advise.

Hi Experts, I am adding a column of numbers with awk , however not getting correct output: # awk '{sum+=$1} END {print sum}' datafile 2.15291e+06 How can I getthe output like : 2152910 Thank you.. # awk '{sum+=$1} END {print sum}' datafile 2.15079e+06 (3 Replies)
Discussion started by: rveri
3 Replies

4. Shell Programming and Scripting

AWK with inconsistent field layout

Input File: 1234567890123456789012345678901234 ---------------------------------- 11111 XXX xxxxx 6666666666 22222 YYY 2222222222 33333 AAA TTT xxxxx 9999999999 44444 55555 RRR UUU 5555555555 66666 TTT nnnnn 2222222222 77777 XXX ... (4 Replies)
Discussion started by: lordsmiter
4 Replies

5. Shell Programming and Scripting

Please help me format with AWK or SED

INPUT FILE: 9780743565219 "GODS OF NEWPORT" "JAKES, JOHN" 2006 OUTPUT FILE I NEED to CREATE FROM INPUT FILE: cd /data/audiobooks/9780743565219 ~/Desktop/mp3-to-m4b 9780743565219-GODS OF NEWPORT "GODS OF NEWPORT" "JAKES, JOHN" 2006 n ---------- Post updated at 04:19 PM ----------... (6 Replies)
Discussion started by: glev2005
6 Replies

6. Shell Programming and Scripting

Format in AWK please

Am new to AWk, Can anyone help me to get excepected output from given input please. input file student: name details of them = details_needed class: 5th_needed adress: address_needed Expected output: details of them = 5th_needed = address_needed ---------- Post updated at... (5 Replies)
Discussion started by: Elavarasan
5 Replies

7. Shell Programming and Scripting

Format using AWK

Need some help .. in formating some input INPUT FILE IMAGE ap00m43 0 0 8 ap00m43_1318914034 UNIX_STANDARD_ADC_2 0 *NULL* root Daily 1 0 1318914034 408 1319518834 0 HISTO -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 FRAG 1 1 0 0 2 20 6 G11890 ts00p71 65536 FRAG 1 2 13440 0 2 20 7 G11890 ts00p71... (2 Replies)
Discussion started by: greycells
2 Replies

8. Shell Programming and Scripting

printf format with awk

Hello Here is an easy one Data file 12345 (tab) Some text (tab) 53.432 23456 (tab) Some longer text (tab) 933.422 34567 (tab) Some different text (tab) 29.309 I need to awk these three tab-delimited columns so that the first two are unchanged (unformatted) and the third shows two decimal... (1 Reply)
Discussion started by: palex
1 Replies

9. Shell Programming and Scripting

awk to format file

Hello, I shall like using the function awk to modify the contents of the following file: /tmp/conf-1 -sec=sys,rw=lpar1:lpar2:lpar3,access=lpar1:lpar2:lpar3 /tmp/conf-2 -vers=4,sec=sys,rw=lpar4:lpar5:lpar6,access=lpar4:lpar5:lpar6 I need to have the result below towards another file ... (5 Replies)
Discussion started by: khalidou13
5 Replies

10. Shell Programming and Scripting

awk Format

Guys ,, pls .. need help with this ... File 1 0A6C Not Visible ???:? NA:NA TDEV N/Grp'd NR 5121 0A6D Not Visible ***:* NA:NA TDEV N/Grp'd RW 33784 0A6E Not Visible ***:* NA:NA TDEV N/Grp'd RW 33784... (4 Replies)
Discussion started by: greycells
4 Replies
curs_printw(3CURSES)					     Curses Library Functions					      curs_printw(3CURSES)

NAME
curs_printw, printw, wprintw, mvprintw, mvwprintw, vwprintw - print formatted output in curses windows SYNOPSIS
cc [ flag ... ] file ... -lcurses [ library ... ] #include <curses.h> int printw(char *fmt, /* arg */ ... ); int wprintw(WINDOW *win, char *fmt, /* arg */ ... ); int mvprintw(int y, int x, char *fmt, /* arg */ ... ); int mvwprintw(WINDOW *win, int y, int x, char *fmt, /* arg */... ); #include <varargs.h> int vwprintw(WINDOW *win, char *fmt, /* varglist */ ... ); DESCRIPTION
The printw(), wprintw(), mvprintw(), and mvwprintw() routines are analogous to printf() (see printf(3C) ). In effect, the string that would be output by printf() is output instead as though waddstr() were used on the given window. The vwprintw() routine is analogous to vprintf() (see vprintf(3C)) and performs a wprintw() using a variable argument list. The third argu- ment is a va_list, a pointer to a list of arguments, as defined in <varargs.h>. RETURN VALUES
All routines return the integer ERR upon failure and an integer value other than ERR upon successful completion. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |MT-Level |Unsafe | +-----------------------------+-----------------------------+ SEE ALSO
curses(3CURSES), printf(3C), vprintf(3C), attributes(5) NOTES
The header <curses.h> automatically includes the headers <stdio.h> and <unctrl.h>. SunOS 5.11 31 Dec 1996 curs_printw(3CURSES)
All times are GMT -4. The time now is 10:22 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy