Sponsored Content
Top Forums Shell Programming and Scripting awk fatal:division by zero attempted bypass with a condtion Post 302820247 by Corona688 on Wednesday 12th of June 2013 11:36:46 AM
Old 06-12-2013
Your code doesn't work at all. Your input has no column 13.

Splitting it into three awks like that has made it really hard to tell which terms you're using for what. I cannot make a program that generates the exact numbers you want; your original does not work at all for me, even for the valid ones, and the one I made generates very different numbers from what you want.

Perhaps if you explained what you did want, instead of asking me to reverse engineer a broken program which doesn't do what you want?

Last edited by Corona688; 06-12-2013 at 12:41 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

error "awk: (FILENAME=- FNR=23) fatal: division by zero attempted"

Hi , I have file : after i run this command : there are error can we print blank line if output error ?? thanks.. ^^ (4 Replies)
Discussion started by: justbow
4 Replies

2. Shell Programming and Scripting

awk error message: division by zero attempted

Hi, I'm executing unixbench tool v4.1 on an embedded system and I'm getting these error messages: Execl Throughput 1 2 3awk: /unixbench/unixbench-4.1.0/pgms/loops.awk:38: (FILENAME=- FNR=4) fatal: division by zero attempted Pipe Throughput 1 2 3 4 5 6 7 8 9 10awk:... (3 Replies)
Discussion started by: rogelio
3 Replies

3. UNIX for Advanced & Expert Users

awk: division by zero

I received error "awk: division by zero" while executing the following statement. SunOS 5.10 Generic_142900-15 sun4us sparc FJSV,GPUZC-M echo 8 | awk 'END {printf ("%d\n",NR/$1 + 0.5);}' file1.lst awk: division by zero Can someone provide solution? Thanks Please use code... (11 Replies)
Discussion started by: kumar77
11 Replies

4. Shell Programming and Scripting

awk division error - 0

input 0 0 9820373 2069 0 0 11485482 awk '{print ($1/$3) / ($4/$7)}' input error Is there any way to fix this problem ? (25 Replies)
Discussion started by: quincyjones
25 Replies

5. Shell Programming and Scripting

variables division with awk

hello i try to divide 2 variables in order to get a percentage--that's why i'm not interested in integer division--but nothing seems to work I think awk is suitable for this but i'm not quite sure how to use it.. any ideas? here's what I want to do: percentage = varA/varB thank you (2 Replies)
Discussion started by: vlm
2 Replies

6. Shell Programming and Scripting

awk - Division with condition

Hi Friends, I have an input file like this cat input chr1 100 200 1 2 chr1 120 130 na 1 chr1 140 160 1 na chr1 170 180 na na chr1 190 220 0 0 chr1 220 230 nd 1 chr2 330 400 1 nd chr2 410 450 nd nd chr3 500 700 1 1 I want to calculate the division of 4th and 5th columns. But, if... (3 Replies)
Discussion started by: jacobs.smith
3 Replies

7. Shell Programming and Scripting

Awk: cmd. line:1: fatal: division by zero attempted

when i try the snippet in the console its working fine: ps awwwux | grep php-fpm | grep -v grep | grep -v master | awk '{total_mem = $6 * 1024 + total_mem; total_proc++} END{printf("%d\n", total_mem / total_proc)}' output: but when i try the bash script: #!/bin/sh # -*- sh -*- #... (3 Replies)
Discussion started by: danieloooo
3 Replies

8. Shell Programming and Scripting

awk Division By Zero Bypass

Hi Friends, I don't understand why "a" is always being printed as zero, when I execute the following command. awk '{if($6||$8||$10||$12==0)a=b=c=d=0;else (a=$5/$6);(b=$7/$8);(c=$9/$10);(d=$11/$12); {print... (6 Replies)
Discussion started by: jacobs.smith
6 Replies

9. Shell Programming and Scripting

Division by zero attempted error during linear conversion of values between 0.25 to 1

I want to implement the below formula with awk oneliner new_value = ((old_value - old_min) / (old_max - old_min) ) * (new_max - new_min) + new_min I want to pass the value of old_min and old_min as variable. Here is what I did for this old_min=$(awk 'BEGIN{a=100000000000}{if ($10<0+a) a=$10}... (2 Replies)
Discussion started by: sammy777888
2 Replies

10. UNIX for Beginners Questions & Answers

Fatal division by zero attempted

Hello. I'm writing an awk script that looks at a .csv file and calculates the weighted grade based on the scores and categories in the file. I keep getting a fatal division by zero attempted error and I know what it means but I've been looking over the code for awhile and am not sure what is... (4 Replies)
Discussion started by: Eric7giants
4 Replies
delta(1)						      General Commands Manual							  delta(1)

Name
       delta - create new SCCS delta to save changes

Syntax
       delta [-rSID] [-s] [-n] [-glist] [-m[mrlist]] [-y[comment]] [-p] files

Description
       The  command  is used to permanently introduce into the named SCCS file changes that were made to the file retrieved by (called the g-file,
       or generated file).

       The command makes a delta to each named SCCS file.  If a directory is named, behaves as though each file in the directory were specified as
       a  named  file,	except	that  non-SCCS	files  (last component of the path name does not begin with s.)  and unreadable files are silently
       ignored.  If a name of - is given, the standard input is read (see RESTRICTIONS); each line of the standard input is taken to be  the  name
       of an SCCS file to be processed.

       The  command may issue prompts on the standard output depending upon certain keyletters specified and flags that may be present in the SCCS
       file.  For further information, see -m and -y keyletters below and

       The includes commentary, input by the user, that consists of one or more lines, terminated by a period (.) in column one of a new line.

       Keyletter arguments apply independently to each named file.

Options
       Keyletter arguments:

       -glist		   Ignores specified list of deltas.

       -m[mrlist]	   Indicates the modification request number.  (-m[mrlist]).

			   If -m is not used and the standard input is a terminal, the prompt MRs?  is issued on the standard  output  before  the
			   standard input is read; if the standard input is not a terminal, no prompt is issued.  The MRs?  prompt always precedes
			   the comments?  prompt (see -y keyletter).

			   MRs in a list are separated by blanks and/or tab characters.  An unescaped new-line character terminates the MR list.

			   Note that if the v flag has a value it is taken to be the name of a program (or shell procedure)  which  will  validate
			   the	correctness  of the MR numbers.  For further information, see If a non-zero exit status is returned from MR number
			   validation program, terminates (it is assumed that the MR numbers were not all valid).

       -n		   Does not delete edited file.

       -p		   Displays differences before and after delta is applied.

       -rSID		   Identifies which delta is to be made to the SCCS file.  Use this keyletter only if two or  more  outstanding  gets  for
			   editing (get -e) on the same SCCS file has been done by the same person (login name).  The SID value specified with the
			   -r keyletter can be either the SID specified on the command line or the SID to be made as reported by the command.  For
			   further  information,  see  A diagnostic results if the specified SID is ambiguous, or, if necessary and omitted on the
			   command line.

       -s		   Suppresses all messages.

       -y[comment]	   Creates delta with specified commentary.  text A null string is considered a valid comment.
			   If -y is not specified and the standard input is a terminal, the prompt comments?  is issued  on  the  standard  output
			   before  the standard input is read; if the standard input is not a terminal, no prompt is issued.  A period (.) in col-
			   umn one of a newline terminates the comment text.

Restrictions
       Lines beginning with an SOH ASCII character (binary 001) cannot be placed in the SCCS file unless the SOH is escaped.  This  character  has
       special meaning to SCCS and will cause an error.  For further information, see

       A  of  many  SCCS  files,  followed  by	a  of those files, should be avoided when the generates a large amount of data.  Instead, multiple
       sequences should be used.

       If the standard input (-) is specified on the command line, the -m (if necessary) and -y keyletters must  also  be  present.   Omission	of
       these keyletters causes an error to occur.

Diagnostics
       See for explanations.

Files
       g-file		   Existed before the execution of removed after completion of

       p-file		   Existed before the execution of delta; may exist after completion of

       q-file		   Created during the execution of removed after completion of

       x-file		   Created during the execution of renamed to SCCS file after completion of

       z-file		   Created during the execution of removed during the execution of

       d-file		   Created during the execution of removed after completion of

       /usr/bin/bdiff	   Program to compute differences between the ``gotten'' file and the g-file.

See Also
       admin(1), bdiff(1), cdc(1), get(1), help(1), prs(1), rmdel(1), sccs(1), sccsfile(5)
       Guide to the Source Code Control System

																	  delta(1)
All times are GMT -4. The time now is 05:02 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy