Sponsored Content
Full Discussion: awk output discrepancy
Top Forums Shell Programming and Scripting awk output discrepancy Post 302884521 by neutronscott on Monday 20th of January 2014 04:34:10 PM
Old 01-20-2014
I'd expect 7, since it's a string in that case. It seems it has to do with when it's converted between a string and int. I've several awk implementations installed locally, oawk is from heirloom tools which should be close to SunOS's.

Code:
$ try() { for awk in gawk mawk oawk bawk; do printf '%s: ' "$awk"; $awk "$@"; done; }
$ try 'BEGIN{ printf "%c\n", "78" }' /dev/null
gawk: 7
mawk: 7
oawk: N
bawk: 7

So what's oawk doing? Well, looks like it's using it as an int ALL THE TIME. I haven't the oawk code around anymore to dig any deeper. Perhaps it has its own printf? I've only known %c to be useful for casting an int to char. But in that first bit, it is internally made an int, unless we tack a null string to it then we're back to getting 7's.

Code:
for awk in gawk mawk oawk bawk; do printf '%s: ' "$awk"; echo 78 | $awk '{ printf "%c\n", $0 "" }'; done;
gawk: 7
mawk: 7
oawk: N
bawk: 7

This User Gave Thanks to neutronscott For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

NIS login discrepancy

I have a query in relation to a couple of machines I have set up. We will call them machine SUN and HPUX and they are running those operating systems respectively. The SUN machine is acting as an NIS server and the HPUX machine as an NIS client. Now the HPUX machine also has a an auto mounted file... (11 Replies)
Discussion started by: Henrik
11 Replies

2. UNIX for Dummies Questions & Answers

How do I get past an HTML::entities discrepancy on an RPM?

I have an RPM that I am trying to install and it keeps coming back with: I know I could kill the bird by throwing a "yum install *perl*" at it, but this seems like hurling a skyscraper at an ant... any better suggestions? (2 Replies)
Discussion started by: jjinno
2 Replies

3. Solaris

Discrepancy in /var/adm/messages

A fresh installation was done in a machine of name arenal1 on Feb 26. But in the /var/adm/messages of the machine, there are messages having date Nov 12. Also the name of the machine is also different in the messages. Can anyone please tell me the reason for this discrepancy. (15 Replies)
Discussion started by: sundar3350
15 Replies

4. Shell Programming and Scripting

AWK: Discrepancy in numeric output

During a file-system cleanup I noticed a strange behavior of awk (HP-UX 11iv3 / IA64). When summing up the size of files in one directory it gives different numbers when using print as opposed to printf: find . -type f -name '*.dmp.Z' -mtime +35 -exec ls -l {} \+ | \ awk 'BEGIN{ OFMT="%f" } {... (1 Reply)
Discussion started by: pludi
1 Replies

5. Shell Programming and Scripting

Discrepancy in finding the top memory consuming processes

When I run 'top' command,I see the following Memory: 32G real, 12G free, 96G swap free Though it shows as 12G free,I am not able to account for processes that consume the rest 20G. In my understanding some process should be consuming atleast 15-16 G but I am not able to find them. Is... (1 Reply)
Discussion started by: prasperl
1 Replies

6. Solaris

Sun X4170 M2 RAM discrepancy

Hi all, We are seeing an odd problem on one of our new servers. It seems to be reporting 4MB less RAM than is installed: # prtconf | grep Mem Memory size: 32764 Megabytes Our other servers for example shows none missing: # prtconf | grep Mem Memory size: 32768 Megabytes Both... (5 Replies)
Discussion started by: wmd
5 Replies

7. Shell Programming and Scripting

Text Highlighting Discrepancy, Caused by SED?

> reverse=`tput rev` > revert=`tput sgr0` > var="This is some note." > echo $var This is some note. > var2="This is ${reverse}some${revert} note." > echo $var2 This is some note. > var3=$(echo $var | sed 's/some/${reverse}some${revert}/g') > echo $var3 This is... (3 Replies)
Discussion started by: adamreiswig
3 Replies

8. Shell Programming and Scripting

Awk script to run a sql and print the output to an output file

Hi All, I have around 900 Select Sql's which I would like to run in an awk script and print the output of those sql's in an txt file. Can you anyone pls let me know how do I do it and execute the awk script? Thanks. (4 Replies)
Discussion started by: adept
4 Replies

9. OS X (Apple)

RAM Usage discrepancy

Hey there! I'm a new user here who registered because I couldn't get these kind of questions answered in the place I directly com from. :o I've found a discrepancy in total RAM used and I can't figure out why it is. My only guess is there are some RAM used by some stuff impossible to identify,... (2 Replies)
Discussion started by: dasx
2 Replies

10. Programming

Memory and cache access time discrepancy

#include<stdio.h> #include<stdlib.h> #include<sys/time.h> #include<time.h> #include "rdtsc.h" #define SIZE 4*64*1024 int main() { unsigned long long a,b; int arr={0}; int i; register int r; a=rdtsc(); r=arr; b=rdtsc(); printf("1st element Access Cycles = %llu\n",b-a); (2 Replies)
Discussion started by: Vaibhavs1985
2 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 04:49 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy