Sponsored Content
Full Discussion: Awking custom output
Top Forums Shell Programming and Scripting Awking custom output Post 302989364 by RudiC on Wednesday 11th of January 2017 02:42:26 PM
Old 01-11-2017
Of course. You messed up the pattern {action} pair structure of awk. Try (untested)

Code:
awk -F, -v SEARCHPATT="(Wed|Tue)" -v ADDISTR="Mon|Tue|Wed|Thu|Fri|Sat|Sun" -vVF="$VALFOUND"
BEGIN           {D[10] = D[13] = 1
                 D[11] = D[14] = 2
                }

$0 ~ "," VF "," {L = 1                                  # start output only if VALFOUND is matched
                }

!L              {next                                   # skip line if NOT VALFOUND
                }

                {A = strftime("%a %b %d %T %Y,%s",$3)
                }

A ~ SEARCHPATT &&
NF in D         {TOT = 0
                 for (n = split ($(NF-D[NF]), T, "="); n>1; n--)    {sub (/_.*/, _, T[n]); TOT += T[n]}

                 if (NF == 11 || A ~ ADDISTR)   print TOT "-" $3 "_" $(NF-D[NF]+1) "----" A
                }
}' datafile.txt

EDIT: Actually, looking at it again, there's another logic flaw: if A ~ "(Wed|Tue)" it will ALWAYS match Mon|Tue|Wed|Thu|Fri|Sat|Sun, so the if in front of the print is pointless.

Last edited by RudiC; 01-11-2017 at 03:56 PM..
This User Gave Thanks to RudiC For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Awking!! Printing decimal output is struck

Hi friends, I have a small problem with AWK. I am not able to print decimal values! :confused: below is my code: #! /bin/awk -f awk BEGIN{printf("%d",123)}; -> This prints the integer properly. x=111 awk BEGIN{printf("%d",x)}; -> This doesnt print! :( Please help me solve this. It... (4 Replies)
Discussion started by: divzz
4 Replies

2. Shell Programming and Scripting

Awking

Could someone find out wht exactly is goin wrong in the following awk: awk '/${EDW_DB_SCHEMA}.WRKR/ || !/otable/&&/${EDW_DB_SCHEMA}.WRKR/ || !/db-ter-load-data/&&/${EDW_DB_SCHEMA}.WRKR/' <my_graph>.ksh Basically, I am trying to achieve: Find out the occurence of WRKR table in <my_graph>.ksh... (3 Replies)
Discussion started by: anduzzi
3 Replies

3. Shell Programming and Scripting

Help with awking

Hi... How does awk or sed or even grep extract the following string out of my text file?. '"${ETL_VW_SCHEMA}"'.IATA_STN_TZ_UTC_LCL_CONV_CV '"${ETL_VW_SCHEMA}"'.CO '"${ETL_VW_SCHEMA}"'.TEST_CO I just need to extract the second entry which means I need to let awk know I am just searching for... (5 Replies)
Discussion started by: anduzzi
5 Replies

4. Shell Programming and Scripting

awking two columns

Hey ppl I have two columns with random values. i need to insert the 1st row of the first column with the highest number of the two rows in the first column and vice versa. some thing like this. I'm sorry If my question is unclear...:rolleyes: input col1 col2 12...11 11...14 34...45... (11 Replies)
Discussion started by: sophiesophie
11 Replies

5. Shell Programming and Scripting

awking two columns based on symbols

The input file has 3 columns. the first column with low values second with bigger.If the symbol is - in third column the numbers have to change the least in column1 and highest in col2. Input col1 col2 col3 1 2 + 2 3 - 3 4 + 5 6 - Output col1 col2 col3 1 2 + 3 2 - 3 4 + 6 5 - The... (2 Replies)
Discussion started by: stateperl
2 Replies

6. HP-UX

Output of Custom package scripts to terminal

Hi, I am doing some testing with creation of depots on HP-UX systems (11.11). Want to display some echo statements based on the processing during checkinstall, pre & postinstall scripts on the terminal. The echo statements are getting directed to /var/adm/sw/swagent.log I want to display... (7 Replies)
Discussion started by: vibhor_agarwali
7 Replies

7. Red Hat

Custom output on FIND

I have a file, ENV.doc somewhere in my home directory. I want to know where the file is located in my sub directories using FIND. But, I want to display only the relative path along with the file name. Thanks, (6 Replies)
Discussion started by: ashok.g
6 Replies

8. Shell Programming and Scripting

Script to output custom characters in different order

Need a script to print a set of characters in different combination. What's the key to accomplish this. e.g charset: "Abcdefghij1" without quotes. block 1: "Abcd" block 2: "efg" block 3: "hij1" I need this script to change the order of the characters and print it to stdout e.g print out... (3 Replies)
Discussion started by: zaonline
3 Replies

9. Shell Programming and Scripting

Custom wget output

The below hides the messy commands of wget #!/bin/bash cd 'C:\Users\cmccabe\Desktop\wget' wget -O getCSV.txt http://172.24.188.113/data/getCSV.csv progressfilt () { local flag=false c count cr=$'\r' nl=$'\n' while IFS='' read -d '' -rn 1 c do if $flag ... (5 Replies)
Discussion started by: cmccabe
5 Replies

10. Shell Programming and Scripting

Awking binary data

i have a binary data that has some text in it. what i want to do is, i want to grab just piece of information from the binary. but when i run my awk on it, it returns nothing. awk -F"MYINFO=" '{print $2}' mybinary however, when i install gawk, then try again, it works. i would prefer... (1 Reply)
Discussion started by: SkySmart
1 Replies
ppmtosixel(1)                                                 General Commands Manual                                                ppmtosixel(1)

NAME
ppmtosixel - convert a portable pixmap into DEC sixel format SYNOPSIS
ppmtosixel [-raw] [-margin] [ppmfile] DESCRIPTION
Reads a portable pixmap as input. Produces sixel commands (SIX) as output. The output is formatted for color printing, e.g. for a DEC LJ250 color inkjet printer. If RGB values from the PPM file do not have maxval=100, the RGB values are rescaled. A printer control header and a color assignment table begin the SIX file. Image data is written in a compressed format by default. A printer control footer ends the image file. OPTIONS
-raw If specified, each pixel will be explicitly described in the image file. If -raw is not specified, output will default to com- pressed format in which identical adjacent pixels are replaced by "repeat pixel" commands. A raw file is often an order of magni- tude larger than a compressed file and prints much slower. -margin If -margin is not specified, the image will be start at the left margin (of the window, paper, or whatever). If -margin is speci- fied, a 1.5 inch left margin will offset the image. PRINTING
Generally, sixel files must reach the printer unfiltered. Use the lpr -x option or cat filename > /dev/tty0?. BUGS
Upon rescaling, truncation of the least significant bits of RGB values may result in poor color conversion. If the original PPM maxval was greater than 100, rescaling also reduces the image depth. While the actual RGB values from the ppm file are more or less retained, the color palette of the LJ250 may not match the colors on your screen. This seems to be a printer limitation. SEE ALSO
ppm(5) AUTHOR
Copyright (C) 1991 by Rick Vinci. 26 April 1991 ppmtosixel(1)
All times are GMT -4. The time now is 05:51 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy