Threshold is less than 0.003 or equal then print the line


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Threshold is less than 0.003 or equal then print the line
# 1  
Old 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
# 2  
Old 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  
Old 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 ----------

Any help please.

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.

Any suggestion please.
Thanks,
Prashant

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

Any suggestion please?
# 4  
Old 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...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

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... (1 Reply)
Discussion started by: TestKing
1 Replies

2. UNIX for Beginners Questions & Answers

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"... (4 Replies)
Discussion started by: balu1234
4 Replies

3. Shell Programming and Scripting

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... (5 Replies)
Discussion started by: LMHmedchem
5 Replies

4. Shell Programming and Scripting

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°)... (2 Replies)
Discussion started by: jcdole
2 Replies

5. Shell Programming and Scripting

If first character doesn't equal '#' and same line contains 'temp', print everything else

(2 Replies)
Discussion started by: snoman1
2 Replies

6. Shell Programming and Scripting

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 ... (14 Replies)
Discussion started by: arm
14 Replies

7. Shell Programming and Scripting

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","","","",""... (2 Replies)
Discussion started by: charles33
2 Replies

8. Shell Programming and Scripting

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... (3 Replies)
Discussion started by: polavan
3 Replies

9. Programming

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 ! (7 Replies)
Discussion started by: aobai
7 Replies

10. Shell Programming and Scripting

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... (7 Replies)
Discussion started by: gillesc_mac
7 Replies
Login or Register to Ask a Question