Sponsored Content
Top Forums Shell Programming and Scripting Using sprintf and system command in awk Post 302969873 by RudiC on Tuesday 29th of March 2016 01:06:00 PM
Old 03-29-2016
OK, how about
Code:
awk -F"|" '
BEGIN           {cfmt   = "%-10s"
                 format = "\t%-10s\t%-20s\t%-14s\t%-14s\t%-32s\n"
                 UL     = sprintf (cfmt format, _, _, _, _, _, _)
                 gsub (" ", "-", UL)
                 printf "%s", UL
                 printf cfmt format, "COUNT", "EVENT_TYPE", "OFFER_NAME", "RESPONSE_CODE", "INTERNAL_ERROR", "FLOWNAME"
                 printf "%s", UL
                 cmd    =  "sort | uniq -c"
                }

END             {close (cmd)
                 printf "%s", UL
                }

$12 ~  "fulfillService" &&
$5  == 2001 &&
$8  != 0    &&
$9  != 0        {match ($14, /externalofferid[^,]*/)
                 printf format, $5, substr ($14, RSTART+18, RLENGTH-19), $8, $9, $(NF-1) | cmd
                }
' file
----------      ----------      --------------------    --------------  --------------  --------------------------------
COUNT           EVENT_TYPE      OFFER_NAME              RESPONSE_CODE   INTERNAL_ERROR  FLOWNAME
----------      ----------      --------------------    --------------  --------------  --------------------------------
      6         2001            EmergencyCreditOffer    -3              114             refillVoucherless
      2         2001            EmergencyCreditOffer    -4              114             refillVoucherless
      1         2001            EmergencyCreditOffer    -5              114             refillVoucherless
      2         2001            EmergencyCreditOffer    -6              114             refillVoucherless
----------      ----------      --------------------    --------------  --------------  --------------------------------

This User Gave Thanks to RudiC For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

can I pass awk variable to system command?

I wanna use a system function to deal with several data. So I use awk variable FILENAME to transfer the file directory to system command, but it does not work. I use a shell function "out_function" to deal with data and save the result in another directory with the same file name. How can I... (2 Replies)
Discussion started by: zhynxn
2 Replies

2. Shell Programming and Scripting

awk system() command not working

I am using Sun Solaris 5.8 I am trying to run a system command such as ls and echo inside awk, but when I run the following code system echo is not displayed. bash-2.03$ ls | awk 'BEGIN { print "first print" system("echo system echo") print "second print" ... (1 Reply)
Discussion started by: rakeshou
1 Replies

3. Shell Programming and Scripting

system command within awk

I was trying commands within awk. i got stuck here. i take 2 files. cat input first second third fourth fifth sixth seventh eighth ninht tenthcat add *************** Nirbhay ***************i run the command awk '{ if ( NR == 5 ) { print system("cat add") "\n" $0 } else {... (4 Replies)
Discussion started by: nirbhay
4 Replies

4. Shell Programming and Scripting

Hide status value from awk system command

Hi, When i use the system( ) function inside a awk, i am getting the ouput with a 0 appended in a new line. Can someone guide me to eliminate the extra line containing 0. Ex : awk -F"|" '{print system("convert.sh" $1}' The output is displayed with 0 in a new line. ... (8 Replies)
Discussion started by: muruganksk
8 Replies

5. Shell Programming and Scripting

Problem with awk awk: program limit exceeded: sprintf buffer size=1020

Hi I have many problems with a script. I have a script that formats a text file but always prints the same error when i try to execute it The code is that: { if (NF==17){ print $0 }else{ fields=NF; all=$0; while... (2 Replies)
Discussion started by: fate
2 Replies

6. Shell Programming and Scripting

awk - System command not working

dear All, my awk system command isn't working or rather I'm missing something in my command. Appreciated , if anyone can assist me what exactly I'm missing ?? awk ' /^/ { > c=split($3,a,"/") ;for(n=1; n<=c; ++n) > { > if (system("test -d" /home/cubedata/20120104/"$1"/"a")) { > print... (5 Replies)
Discussion started by: manas_ranjan
5 Replies

7. Shell Programming and Scripting

Invoking system(cmd) inside awk command

Hi, I was searching for a way to grep 2 lines before and after a certain keyword, and I came across the following code.. awk "\$0 ~ /ORA-/ { cmd=\"awk 'NR>=\" NR-2 \" && NR<=\" NR+2 \"' init.ora\" system(cmd) }" input_file I could not understand how this works. What is system() ? what... (2 Replies)
Discussion started by: Kulasekar
2 Replies

8. Shell Programming and Scripting

How can I pass arguments to system command in a awk script?

Hi I need your help, please How can I pass arguments to system command in a awk script?... for example: byte=substr(cadena,pos,2); system("grep -n byte mapeo.txt"); Does it exist a way? Thanks for advance. (4 Replies)
Discussion started by: solaris21
4 Replies

9. Shell Programming and Scripting

Awk: System command not working in awk

Hi, I have around 10 files in a folder in which I want to change the file format from tab(\t) to pipe(|) with some changes in the fields as well. Below is the code, while tmp file is getting generated but move command is not working, please help Following is the code awk -F"\t" '{print... (2 Replies)
Discussion started by: siramitsharma
2 Replies

10. UNIX for Dummies Questions & Answers

Join with awk using sprintf

Hi, Trying to join 2 files with awk (file1 has variable number of fields; file 2 has constant number of fields) file1: hook1|AA|BB|CC|DD hook2|EE|FF file2: hook1|11|22 hook2|33|44 hook3|55|66 output: hook1|11|22|AA|BB|CC|DD hook2|33|44|EE|FF hook3|55|66 What I tried so far:... (3 Replies)
Discussion started by: beca123456
3 Replies
SDL_ListModes(3)						 SDL API Reference						  SDL_ListModes(3)

NAME
SDL_ListModes - Returns a pointer to an array of available screen dimensions for the given format and video flags SYNOPSIS
#include "SDL.h" SDL_Rect **SDL_ListModes(SDL_PixelFormat *format, Uint32 flags); DESCRIPTION
Return a pointer to an array of available screen dimensions for the given format and video flags, sorted largest to smallest. Returns NULL if there are no dimensions available for a particular format, or -1 if any dimension is okay for the given format. If format is NULL, the mode list will be for the format returned by SDL_GetVideoInfo()->vfmt. The flag parameter is an OR'd combination of surface flags. The flags are the same as those used SDL_SetVideoMode and they play a strong role in deciding what modes are valid. For instance, if you pass SDL_HWSURFACE as a flag only modes that support hardware video surfaces will be returned. EXAMPLE
SDL_Rect **modes; int i; . . . /* Get available fullscreen/hardware modes */ modes=SDL_ListModes(NULL, SDL_FULLSCREEN|SDL_HWSURFACE); /* Check is there are any modes available */ if(modes == (SDL_Rect **)0){ printf("No modes available! "); exit(-1); } /* Check if or resolution is restricted */ if(modes == (SDL_Rect **)-1){ printf("All resolutions available. "); } else{ /* Print valid modes */ printf("Available Modes "); for(i=0;modes[i];++i) printf(" %d x %d ", modes[i]->w, modes[i]->h); } . . SEE ALSO
SDL_SetVideoMode, SDL_GetVideoInfo, SDL_Rect, SDL_PixelFormat SDL
Tue 11 Sep 2001, 23:01 SDL_ListModes(3)
All times are GMT -4. The time now is 05:59 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy