comp.lang.awk
  Home FAQ Contact Sign in
comp.lang.awk only
 
Advanced search
July 2008
motuwethfrsasuw
 123456 27
78910111213 28
14151617181920 29
21222324252627 30
28293031    31
2008
 Jan   Feb   Mar   Apr 
 May   Jun   Jul   Aug 
 Sep   Oct   Nov   Dec 
2008 2007 2006  
total
comp.lang.awk Profile…
RELATED GROUPS

POPULAR GROUPS

more...

 Up
  AWK with different decimal separator on different Linux distros?         


Author:
Date: Jul 17, 2008 02:41

Hi all,
I noticed an obscurity which took me some time to debug. It seems that
AWK on Fedora Core has a different decimal separator (comma:,) than on
other Distro (point .) which leads to enourmous calculation
differences on different distros.

on Debian based systems:

$ cat /etc/*release*
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=8.04
DISTRIB_CODENAME=hardy
DISTRIB_DESCRIPTION="Ubuntu 8.04.1"
$ echo "12.345" | awk '{print $1+2}'
14.345
$ echo "12,345" | awk '{print $1+2}'
14
$

on Fedora Core:
Show full article (0.89Kb)
6 Comments
  awk field order (cpm)         


Author: sandy_eggo
Date: Jul 14, 2008 16:52

Given a record that looks like:
Department: PEDIATRICS/TRIHEALTH

Using awk how can I print the record so it looks like:
Department: TRIHEALTH/PEDIATRICS

(basically print $2 and $1 with an OFS = "/"). I've tried several
iterations and.
just. can't. get. it. today.
2 Comments
  multiple records         


Author: nhgokulprasad
Date: Jul 12, 2008 23:15

Hi,

I have output which looks as follows
abc@xyz blah blah
something something something
othersomething othersomtheing othersomething

and the above 3 line repeated for some 100 times(with different
setting) so i have 300 lines. I want to get print
abc@xyz from 1st lineHi,

I have output which looks as follows
abc@xyz blah blah
something something something
othersomething othersomtheing othersomething

and the above 3 line repeated for some 100 times(with different
setting) so i have 300 lines. I want to get print
abc@xyz from 1st line
11 Comments
  Re: "Effective awk programming"         


Author: Spiros Bousbouras
Date: Jul 12, 2008 09:44

On Jul 11, 6:51 am, Spiros Bousbouras gmail.com> wrote:
> The O'Reilly version of "Effective awk programming" came out in
> 2001. The version on the GNU website (http://www.gnu.org/manual/gawk)
> is copyrighted 2004, 2006. So I'm wondering are there important
> differences between the online version and the printed version ?
> Does anyone have any idea whether a more recent printed version is
> planned ?

Noone ? Ok , let's try a different approach. Has it ever happened to
you
that you found information out of date in the printed book ? If yes
how
serious was it ?
1 Comment
  gawk for windows: system() does not yield exit status         


Author: Ronny
Date: Jul 11, 2008 03:08

I found that when executing

status=system('myprog')

on Windows 2000, status is *always* zero afterwards,
even if myprog sets an exit code.

Can someone explain why this is so?

Is there a way to run an external program and get its exit
code on Windows?

Ronald
37 Comments
  "Effective awk programming"         


Author: Spiros Bousbouras
Date: Jul 10, 2008 22:51

The O'Reilly version of "Effective awk programming" came out in
2001. The version on the GNU website (http://www.gnu.org/manual/gawk)
is copyrighted 2004, 2006. So I'm wondering are there important
differences between the online version and the printed version ?
Does anyone have any idea whether a more recent printed version is
planned ?
no comments
  gawk integer conversions         


Author: stevecalfee
Date: Jul 10, 2008 09:23

Hi,

I am trying to pretty print some data presented as a bunch of hex
bytes:

0xf0 0xd8 - for a 16 bit example.

I use:
#little endian build a number
arg = 0
for (i = fld + len; i > fld ; i--) {
arg = (arg * 256) + strtonum($(i))
}

And this does collect the multi byte number 0xd8f0 and I can print it
as 55536 in decimal.

The problem is the data is signed. So -1 is represented as one byte of
0xff - which the above conversion will give me as 255.

Since gawk actually holds numbers as double floats, how can I sign
extend the integer sign?

Thanks, Steve
5 Comments
  Using a regexp as field separator does not work!         


Author: Ronny
Date: Jul 10, 2008 07:01

I'm using gawk 3.1.0 (Windows native) and 3.1.6 (Cygwin). My input
file
contains fields which are separated by a vertical, optionally followed
by
spaces. Here is a small test program for this file format:

BEGIN {
print "run starts"
FS="| *"
}

{
print "processing line with",NF,"fields {",$0,"}"
}

When using the following 2-line input file:

# set art
0,1,4|set art

I get as output:

run starts
processing line with 3 fields { # set art }
processing line with 2 fields { 0,1,4|set art }
Show full article (0.59Kb)
15 Comments
  syntax error         


Author: dnlchen
Date: Jul 7, 2008 15:47

# awk 'BEGIN {min=9999999} $NF > max {max=$NF; maxline=$0}; $NF < min
{min=$NF; minline=$0} END {print max, maxline "\n" min, minline}'
access.log
3190709 192.168.1.200 - - [07/Jul/2008:15:53:38 +0000] "GET /700.xml
HTTP/1.0" 200 24634 3190709
193 192.168.1.200 - - [06/Jul/2008:21:25:40 +0000] "GET /audio/vm/
Numbers%%20(0).wav HTTP/1.0" 304 - 193
Show full article (1.42Kb)
2 Comments
  syntax error         


Author: dnlchen
Date: Jul 7, 2008 14:12

# awk 'BEGIN {min=9999999} $NF > max {max=$NF; maxline=$0}; $NF < min
{min=$NF; minline=$0} END {print max, maxline "\n" min, minline}'
access.log
3190709 192.168.1.200 - - [07/Jul/2008:15:53:38 +0000] "GET /700.xml
HTTP/1.0" 200 24634 3190709
193 192.168.1.200 - - [06/Jul/2008:21:25:40 +0000] "GET /audio/vm/
Numbers%%20(0).wav HTTP/1.0" 304 - 193
Show full article (1.42Kb)
4 Comments
 
1 2 3 4 5 6 7 8 9