## Threshold is less than 0.003 or equal then print the line

Threshold is less than 0.003 or equal then print the line
# 1
07-28-2009
Threshold is less than 0.003 or equal then print the line

Friends,

I have very large data files (File1 and File2).
Search field1 of File1 into Field1 of File2.
If found then do Field1 of File1 MINUS Field1 of File2
if the answer is <= 0.003 (positive or negative) then
print that line from File1.

File1
ABC1231|1.1111|2.2122|3.3133
ABC1232|1.1211|2.2222|3.3233
ABC1233|1.1311|2.2322|3.3333

File2
ABC1231|1.1111|2.2122|3.3133
ABC1232|1.1211|2.2222|3.3233
ABC1233|1.1311|2.2322|3.3333
ABC1234|1.1411|2.2422|3.3433
ABC1235|1.1511|2.2522|3.3533

Thanks,
Prashant
 ppat7046 View Public Profile for ppat7046 Find all posts by ppat7046
# 2
07-28-2009
what do you mean by field1 of file1 minus field1 of file2???
1.1111-1.1111
or
2.2122-2.2111???
# 3
07-29-2009
I am sorry. Let me be more specific.

I have two files. When I do diff I get some difference. Like below.
Up to .003 difference is ok but diff fails the comparision.

File1: ABC1231|-2.306|0.0121|9.766
File2: ABC1231|-2.305|0.0123|9.767

So what I thought was following:
-2.306 minus -2.305 is less than or equal to 0.003 than it pass
0.0121 minus 0.0123 is less than or equal to 0.003 than it pass
9.766 minus 9.767 is less than or equal to 0.003 than it pass

---------- Post updated 07-29-09 at 10:12 AM ---------- Previous update was 07-28-09 at 04:31 PM ----------

All I am trying to do is diff between two files.

File1: ABC1231|-2.306|0.0121|9.766
File2: ABC1231|-2.305|0.0123|9.767

However, the last digit in field 2, 3 and 4 are different it fails.
If the difference of the last digit is less than or equal to .003 than I need to pass.

Thanks,
Prashant

---------- Post updated at 02:37 PM ---------- Previous update was at 10:12 AM ----------

 ppat7046 View Public Profile for ppat7046 Find all posts by ppat7046
# 4
07-29-2009
A general suggestion would be:
1.) grep line 1 of both files for the characters up to the pipe character. Save each search as a separate variable.
2.) Compare both variables and if they have the same content, proceed to grep-ing the rest of the contents of line 1 of each file putting each number between pipe characters into separate variables, or even better compare them right in the loop for the desired difference. You could send the output of the loop to standard output via echo at that point...
 varelg View Public Profile for varelg Find all posts by varelg

Test Your Knowledge in Computers #182
Difficulty: Medium
yq is a lightweight and portable command-line CSV processor.
True or False?

## How to print out with equal spacing between columns?

For instance, my file contains the following content... set -A array set -A test \${array}=1 \${array}=2 \${array}=3 \${test}="Boy" \${test}="Girl" \${test}="Dog" x=0 while ;do print "\${array}" " " "\${test}" x=\$((x+1) done...

## Reading a file line by line and print required lines based on pattern

Hi All, i want to write a shell script read below file line by line and want to exclude the lines which contains empty value for MOUNTPOINT field. i am using centos 7 Operating system. want to read below file. # cat /tmp/d5 NAME="/dev/sda" TYPE="disk" SIZE="60G" OWNER="root"...

## Find line then evaluate text on next line, print when condition is met

Hello, I am looking for a specific situation in a text file. The conditions are, > <CompoundName> InChI=1S/C5H12NO2/c1-5(2)4-8-6(3)7/h5H,4H2,1-3H3/q+1 I am looking for cases where the line "> <CompoundName>" is followed by a line that contains the string "InChI=" without regard to...

## sed - How to replace right part of equal sign (=) on a line

Hello. Using a bash script , I have a variable name for the file I want to modify FILE_TO_EDIT="/etc/my_config_file"And I have a variable name for the parameter to change PARAMETER="fallback_node" PARAMETER_NEW_VALUE="http://my_server_name.com/new_path" A config file may contain : 1°)...

## awk to print record not equal specific pattern

how to use "awk" to print any record has pattern not equal ? for example my file has 5 records & I need to get all lines which \$1=10 or 20 , \$2=10 or 20 and \$3 greater than "130302" as it shown : 10 20 1303252348212B030 20 10 1303242348212B030 40 34 1303252348212B030 10 20 ...

## Using awk, print all the lines where field 8 is equal to x

Using awk, print all the lines where field 8 is equal to x I really did try, but this awk thing is really hard to figure out. file1.txt"Georgia","Atlanta","2011-11-02","x","","","","" "California","Los Angeles","2011-11-03","x","","","",""...

## Print pipe separated list as line by line in Korn Shell

Korn Shell in AIX 6.1 I want to print the below shown pipe (|) separated list line by line. line=es349889|nhb882309|ts00293|snh03524|bg578835|bg37900|rnh00297|py882201|sg175883 for i in line do echo "Hello \$line " done I wanted to execute the above for loop. But i can't even set the...

## Catch signal SIGPIPE print errno but it's value equal to 2

catch signal SIGPIPE ,print errno but it's value equal to 2(ENOENT) #define ENOENT 2 /* No such file or directory */ is it should be EPIPE ? #define EPIPE 32 /* Broken pipe */ Thanks !

## Compare multiple fields in file1 to file2 and print line and next line

Hello, I have two files that I need to compare and print out the line from file2 that has the first 6 fields matching the first 6 fields in file1. Complicating this are the following restrictions 1. file1 is only a few thousand lines at most and file2 is greater than 2 million 2. I need to...