Sponsored Content
Full Discussion: Awk: Error with END
Top Forums Shell Programming and Scripting Awk: Error with END Post 303011145 by genome on Saturday 13th of January 2018 09:56:20 PM
Old 01-13-2018
Quote:
Originally Posted by MadeInGermany
Yes, and the indention improves readability!

Normally you should test for existence if (!($2 in snp))
and not for a zero/empty value if (!snp[$2])
MadeInGermany: Thanks for the tip. Smilie
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk : delete ^M at the end of the line

Hi all, I'm newbi in scripting. could someone tell how to delete the ^M at the end of the linie with an awk command. many thanks in advance. (2 Replies)
Discussion started by: liliput
2 Replies

2. Shell Programming and Scripting

AWK end of line question

Any clues on how to parse a line returned from an ls command that allows for the filename to be fully passed even if it includes spaces? What I got close with is: ls -ltra | awk '{print $1 "|" $3 "|" $4 "|" $5 "|" $6 "|" $7 "|" $8 "|" $9 $10 $11 $12 ... (etc)}' However this clears the spaces in... (6 Replies)
Discussion started by: jpport123
6 Replies

3. UNIX and Linux Applications

Print date at END clause of AWK

Hi to all! I 'm new in unix programing so... may be I decided a wrong tool to solve the problem but anyway... all road goes to rome jajaja. My question is: There is any way to print date at the END clause of an AWK script. I mean, I'm writing a tool with AWK and the results are redirected to a... (4 Replies)
Discussion started by: fmeriles
4 Replies

4. Shell Programming and Scripting

End of file in AWK

Hello! I need to control when i arrive to the end of my file, any built-in? or another way to do? Thanks! (4 Replies)
Discussion started by: claw82
4 Replies

5. Shell Programming and Scripting

awk get rid of space in end of field

Hello. I'm using a file to "grep" in a 2nd one (with awk) cat file1 2 first user 9 second user 1 third user (with a space after user) I want to get the line except the 1st field so I do : field=$(gawk '{$1 =""; print $0}' file | sed 's/^ //') It works but it deletes... (5 Replies)
Discussion started by: xanthos
5 Replies

6. Shell Programming and Scripting

awk - end of line - Help!

I have a textfile which I am parsing with awk. The lines do not have the same number of fields, so sometimes $3 is the last field, sometimes not. When I do a 'printf("%s, %s\n", $2, $3)', if $3 is the last field in the line, when I cat the file the output looks something like this:... (3 Replies)
Discussion started by: dmesserly
3 Replies

7. Shell Programming and Scripting

BEGIN and END format in awk

I'm new to awk, trying to understand the basics. I'm trying to reset the counter everytime the program gets a new file to check. I figured in the BEGIN part it would work, but it doesn't. #!/bin/awk -f BEGIN {counter=0} { sum=0 for ( i=1; i<=NF;... (1 Reply)
Discussion started by: guitarist684
1 Replies

8. Shell Programming and Scripting

IF section problem. syntax error: unexpected end of file error

Hello, I have another problem with my script. Please accept my apologies, but I am really nooby in sh scripts. I am writing it for first time. My script: returned=`tail -50 SapLogs.log | grep -i "Error"` echo $returned if ; then echo "There is no errors in the logs" fi And after... (10 Replies)
Discussion started by: jedzio
10 Replies

9. UNIX for Dummies Questions & Answers

awk until the end of file

Hi, I tried to use a code to awk until the end of file. I not sure what is the syntax so my last paragraph is \n `var=$(awk '/\n/ {P=0} /Policy Change/ {P=1} P' (2 Replies)
Discussion started by: alvinoo
2 Replies
math::fuzzy(n)							 Tcl Math Library						    math::fuzzy(n)

__________________________________________________________________________________________________________________________________________________

NAME
math::fuzzy - Fuzzy comparison of floating-point numbers SYNOPSIS
package require Tcl ?8.3? package require math::fuzzy ?0.2? ::math::fuzzy::teq value1 value2 ::math::fuzzy::tne value1 value2 ::math::fuzzy::tge value1 value2 ::math::fuzzy::tle value1 value2 ::math::fuzzy::tlt value1 value2 ::math::fuzzy::tgt value1 value2 ::math::fuzzy::tfloor value ::math::fuzzy::tceil value ::math::fuzzy::tround value ::math::fuzzy::troundn value ndigits _________________________________________________________________ DESCRIPTION
The package Fuzzy is meant to solve common problems with floating-point numbers in a systematic way: o Comparing two numbers that are "supposed" to be identical, like 1.0 and 2.1/(1.2+0.9) is not guaranteed to give the intuitive result. o Rounding a number that is halfway two integer numbers can cause strange errors, like int(100.0*2.8) != 28 but 27 The Fuzzy package is meant to help sorting out this type of problems by defining "fuzzy" comparison procedures for floating-point numbers. It does so by allowing for a small margin that is determined automatically - the margin is three times the "epsilon" value, that is three times the smallest number eps such that 1.0 and 1.0+$eps canbe distinguished. In Tcl, which uses double precision floating-point numbers, this is typically 1.1e-16. PROCEDURES
Effectively the package provides the following procedures: ::math::fuzzy::teq value1 value2 Compares two floating-point numbers and returns 1 if their values fall within a small range. Otherwise it returns 0. ::math::fuzzy::tne value1 value2 Returns the negation, that is, if the difference is larger than the margin, it returns 1. ::math::fuzzy::tge value1 value2 Compares two floating-point numbers and returns 1 if their values either fall within a small range or if the first number is larger than the second. Otherwise it returns 0. ::math::fuzzy::tle value1 value2 Returns 1 if the two numbers are equal according to [teq] or if the first is smaller than the second. ::math::fuzzy::tlt value1 value2 Returns the opposite of [tge]. ::math::fuzzy::tgt value1 value2 Returns the opposite of [tle]. ::math::fuzzy::tfloor value Returns the integer number that is lower or equal to the given floating-point number, within a well-defined tolerance. ::math::fuzzy::tceil value Returns the integer number that is greater or equal to the given floating-point number, within a well-defined tolerance. ::math::fuzzy::tround value Rounds the floating-point number off. ::math::fuzzy::troundn value ndigits Rounds the floating-point number off to the specified number of decimals (Pro memorie). Usage: if { [teq $x $y] } { puts "x == y" } if { [tne $x $y] } { puts "x != y" } if { [tge $x $y] } { puts "x >= y" } if { [tgt $x $y] } { puts "x > y" } if { [tlt $x $y] } { puts "x < y" } if { [tle $x $y] } { puts "x <= y" } set fx [tfloor $x] set fc [tceil $x] set rounded [tround $x] set roundn [troundn $x $nodigits] TEST CASES
The problems that can occur with floating-point numbers are illustrated by the test cases in the file "fuzzy.test": o Several test case use the ordinary comparisons, and they fail invariably to produce understandable results o One test case uses [expr] without braces ({ and }). It too fails. The conclusion from this is that any expression should be surrounded by braces, because otherwise very awkward things can happen if you need accuracy. Furthermore, accuracy and understandable results are enhanced by using these "tolerant" or fuzzy comparisons. Note that besides the Tcl-only package, there is also a C-based version. REFERENCES
Original implementation in Fortran by dr. H.D. Knoble (Penn State University). P. E. Hagerty, "More on Fuzzy Floor and Ceiling," APL QUOTE QUAD 8(4):20-24, June 1978. Note that TFLOOR=FL5 took five years of refereed evolution (publication). L. M. Breed, "Definitions for Fuzzy Floor and Ceiling", APL QUOTE QUAD 8(3):16-23, March 1978. D. Knuth, Art of Computer Programming, Vol. 1, Problem 1.2.4-5. BUGS, IDEAS, FEEDBACK This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category math :: fuzzy of the Tcllib SF Trackers [http://sourceforge.net/tracker/?group_id=12883]. Please also report any ideas for enhancements you may have for either package and/or documentation. KEYWORDS
floating-point, math, rounding math 0.2 math::fuzzy(n)
All times are GMT -4. The time now is 11:58 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy