Sponsored Content
Full Discussion: Weird awk problem
Top Forums Shell Programming and Scripting Weird awk problem Post 302918748 by Scrutinizer on Thursday 25th of September 2014 09:15:17 AM
Old 09-25-2014
You're welcome. It is not entirely surprising.. If the variable a is not initialized then it is the empty string ("").. So $a becomes $"".

Some awks may interpret it in a numerical context and change it to 0 and so it turns into $0 (which is the record), which would give the proper answer, but it would work differently from what you might expect...

Other awks may not accept $"" and raise an error message

Yet other awks may assign it to $0 (because it is a numerical context), but reference $"" which may return 0, etc...

It is an ambiguous situation and it really depends on the specific awk implementation how this improper use of the variable gets handled..
This User Gave Thanks to Scrutinizer For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Weird Problem???

I have a problem I don't understand... I am trying to declare a variable, and then output the results of that variable, couldn't be simpler #!/bin/ksh VAR='Oranges' if then echo "Found Lemons" elif then echo "Found Oranges" fi The output shouold clearly be "Found Oranges", but... (2 Replies)
Discussion started by: danhodges99
2 Replies

2. Solaris

Weird crontab problem

Greetings To All! I am running Solaris 10 in a sparc environment. Here is the deal: In /var/spool/cron/crontabs, there is a cron user named "sys". If I do a crontab -l sys, it returns: # 0 * * * 0-6 /usr/lib/sa/sa1 # 20,40 8-17 * * 1-5 /usr/lib/sa/sa1 # 5 18 * * 1-5 /usr/lib/sa/sa2... (8 Replies)
Discussion started by: RobSand
8 Replies

3. Shell Programming and Scripting

Weird date difference problem

I am trying to find the difference in days between 2 dates. I have to extract the 1st date from a filename, which i did using the awk command. I have to compare this date to today's date and if the difference is greater than 30 days, do something, else do something else. This is what i wrote... (22 Replies)
Discussion started by: meeraKh
22 Replies

4. Shell Programming and Scripting

Weird Variable Evaluation problem

Hi Guys.. I have a script which is: #!/bin/ksh for file in `grep qtc $PIC_SHS/xback00.ksh |cut -d"=" -f2` do ls $file cp $file ./ done output of grep is $ grep qtc $PIC_SHS/xback00.ksh |cut -d"=" -f2 $PIC_BIN/XPBACKRC0.qtc $PIC_BIN/XPBACK000.qtc $PIC_BIN/XPBACKSS0.qtc... (2 Replies)
Discussion started by: vamsi.coe
2 Replies

5. UNIX for Advanced & Expert Users

Really weird delete problem

Hi, I've Ubuntu 8.04, and it has some files that I just cannot delete. I've tried everything, inode, fsck etc. Here is what the ls -li outputs root@ubuntu:/home/luser/.local/share/Trash/files/junk# ls -l ls: cannot access TRUNK_: No such file or directory ls: cannot access 2006_output.mv:... (11 Replies)
Discussion started by: nitin
11 Replies

6. Infrastructure Monitoring

Weird dependency problem!

Hi, I want to install net-snmp-devel package but i have following dependecy problem. It's very odd, i don't get it. One of packages is depended on the other one, the other one is depended on the previous one as well. :S :S Could you help me please? Here are the steps: # ls -l total... (4 Replies)
Discussion started by: oduth
4 Replies

7. Shell Programming and Scripting

awk weird problem.

awk 'BEGIN{print 1.2.3.4}' 1.20.30.4 Can anyone explain why has extra "0" in the IP address? (3 Replies)
Discussion started by: newoz
3 Replies

8. Programming

A weird problem with POSIX function

Hi all, Sorry for the title because I didn't find a proper name for it. My question is about POSIX functions, such as timer_create(), mq_open() and pthread_create(). void test_queue() { struct mq_attr attr; attr.mq_maxmsg = 10; attr.mq_msgsize = 64; mq_unlink("/my_test_queue");... (6 Replies)
Discussion started by: bus147
6 Replies

9. Shell Programming and Scripting

A very weird problem about getting a random string

Hi, guys Here is my script and it's an imaginary script to recast a string randomly. #!/bin/bash # scriptname: recast_string # purpose: recast a string randomly like this "abc123" --> "21a3cb" or "a31b2c" function recast() { local original_string=$1 local... (4 Replies)
Discussion started by: franksunnn
4 Replies

10. UNIX for Dummies Questions & Answers

Weird problem with join command

I have a weird issue going on with the join command... I have two files I am trying to join...here is a line from each file with the important parts marked in red: file1: /groupspace/ccops/cmis/bauwkrcn/commsamp_20140315.txt,1 file2:... (3 Replies)
Discussion started by: dbiggied
3 Replies
MAPHIMBU(1)							   User Commands						       MAPHIMBU(1)

NAME
maphimbu - histogram builder for 1-d numerical and text data SYNOPSIS
maphimbu [OPTION]... [FILE] DESCRIPTION
This program produces 1-d histograms from numerical or text data input. It can be also used to estimate the probability distribution func- tion of a numerical variable - see http://en.wikipedia.org/wiki/Probability_density_function. OPTIONS
-x <int> x-data column (default is 1) -y <int> y-data column (default is 2); It is considered only when combined with '-m' or '-S' -d <float|int> delta size (dx-resolution) in case of numerical data; Keep in mind that 2 is not the same as 2.0: in the first case the numbers are treated as integers, in the latter as floats. -n normalize the result A) non-numerical data: n(x) = counts(x)/sum_of_counts B) numerical data: the normalized probability density func. is P(-INF < x <INF) = Int_[-INF:INF] P(x)*dx = 1 ; For the numerical integration an open x-data interval is assumed. -N normalize data against the total sum of counts (same as option '-n' with case A forced) -U normalize the result with x-range mapped to unit; The x-values are mapped to the interval [0:1], respectively Int_[0:1] P(x)*dx = 1; This option is mutually exclusive with '-n'. -S compute sums and normalized sums of y-values; The total sum of all y-values is used for the normalization. -m compute the arithmetic mean of y-values in the respective x-bar -s <int> sort output using the specified column; Header is skipped in this case. -g <int> sort output numerically using the specified column; Header is skipped in this case. -r do reverse sorting (in combination with '-g' and '-s') -C center histogram bars (shifts x-axis by 0.5*dx) -X treat hole line as one string (single data record) -H print a data description header -V print program version and exit --version output version and copyright information --help display help -h display short help (options summary) Note: this program is not intended for use in high order numerical computations. REPORTING BUGS
Report bugs to <gnu@mirendom.net> COPYRIGHT
Copyright (C) 2003-2007, 2009, 2011 Dimitar Ivanov License: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. maphimbu 2.8.4 February 2012 MAPHIMBU(1)
All times are GMT -4. The time now is 10:27 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy