Sponsored Content
Top Forums Shell Programming and Scripting Compare colunmn and find value within a ranges Post 302964292 by giuliangiuseppe on Wednesday 13th of January 2016 07:33:49 AM
Old 01-13-2016
Compare colunmn and find value within a ranges

Dear All,
sorry for open a new thread but the old one (Find values within range and output) is already marked as resolved but actually it doesn't work properly and the input file are a bit different.

File 1:

Code:
1 195240910 +
2 195240915 -

File2:
Code:
1 195240905 4
1 195240906 4
1 195240907 5
1 195240908 5
1 195240909 3
1 195240910 0
1 195240911 5
1 195240912 5
1 195240913 0
1 195240914 0
1 195240915 3
1 195240916 4
1 195240917 5
1 195240918 8
1 195240919 5
1 195240920 6
2 195240905 7
2 195240906 2
2 195240907 9
2 195240908 9
2 195240909 2
2 195240910 12
2 195240911 2
2 195240912 9
2 195240913 5
2 195240914 9
2 195240915 0
2 195240916 2
2 195240917 9
2 195240918 5
2 195240919 9
2 195240920 6

Well, I would like to compare these two files in this way.
first, column $1 and $2 of both files must match, if so, output the matching values and if column $3 of file 1 is
Code:
+

output the less n value of $3 in File2, otherwise if column $3 of file 1 is
Code:
-

output the more n value of $3 in File2.

so for File1 and File2 output should be (for n=5):

Code:
1 195240910 4 5 5 3 0
2 195240915 9 5 9 2 0

Well, I really hope that color could help to understand.
Any help or suggestion?

Best
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

script to compare first column of two files and find difference

Hi, I want to write a script which will compare the 1st column of both the files and will give the difference. e.g:- my 1st file contains: 89 /usr 52 /usr/local 36 /tmp 92 /opt 96 /home 27 /etc/opt/EMCom 1 ... (3 Replies)
Discussion started by: adityam
3 Replies

2. Shell Programming and Scripting

find command: various date ranges

Hi, I have writtena script that will recursivly go into subdirecotries and report out what files there are in there that have not been accessed over various date ranges. I do this using a number of find commands: find . -path './.snapshot' -prune -o -type f -atime -8 find... (4 Replies)
Discussion started by: littleIdiot
4 Replies

3. HP-UX

Compare 2 systems to find any differences

Hi there, I have 2 machines running HP-UX. One off these controllers is able to send mail and the other cannot. I have looked at all the settings that I know and coannot find any differences. Is there a way to audit the 2 machinces by pulling all the settings then compare any differences? ... (2 Replies)
Discussion started by: lodey
2 Replies

4. Shell Programming and Scripting

Compare two sample files and find common

Hi I have two sample files attached here one file contain entries in one column and second file contains entries in many columns I have to match entries of first file with entries in secon d file form secon column onwards and if matches write "match" in front of it. I tried several... (11 Replies)
Discussion started by: manigrover
11 Replies

5. Shell Programming and Scripting

To find and compare the data

hi , from the awk command i'm getting the output where the 2nd column of both are match in row wise, if it present in that same column some where else, I cannot get the correct output. awk 'FNR==NR {a=$5;next} $1 in a {if ($5==a) t=0; else {t=$5-a};print $0,t}' file.tsv file2.tsv please... (3 Replies)
Discussion started by: Shenbaga.d
3 Replies

6. Shell Programming and Scripting

Compare the output of find command

Hi All, I am trying to run find command in a script to list out certain files based on a patter. However, when there is no file in the output, the script should exit. Tried a couple of operators (-n, -z) etc but the script does not work. I am confused whether a null string is returned... (3 Replies)
Discussion started by: danish0909
3 Replies

7. Shell Programming and Scripting

Compare and find records of file1 not in file2

hi.. i am using solaris system and ksh and using nawk to get records of file1 not in file2(not line by line comparison). code i am using is nawk 'NR==FNR{a++} !a {print"line:" FNR"->" $0} ' file2 file1 same command with awk runs perfectly on darwin kernel(mac) but in solaris it does line by... (2 Replies)
Discussion started by: Abhiraj Singh
2 Replies

8. Shell Programming and Scripting

Find and compare values from different txt files

Hello, i am new in Bash. Actually i have a directory : /home/resultfiles and inside i have these txt files: 531_1.out.res, 531_2.out.res , 531_3.out.res 532_1.out.res, 532_2.out.res , 532_3.out.res 533_1.out.res, 533_2.out.res, 533_3.out.res All these txt files has this format : num_q all... (3 Replies)
Discussion started by: nimpoura
3 Replies

9. Shell Programming and Scripting

Compare 2 files and find missing fields awk

Hello experts! I have 2 files. file1 is a list file containing uniquely names. e.g.: name1 number number name2 number number name5 number number name10 number number ... file2 is a data file arbitrary containing the names of file1 in paragraphs separated by "10" e.g. name4 ... (3 Replies)
Discussion started by: phaethon
3 Replies
set_color(1)							       fish							      set_color(1)

NAME
set_color - set_color - set the terminal color set_color - set the terminal color Synopsis set_color [-v --version] [-h --help] [-b --background COLOR] [COLOR] Description Change the foreground and/or background color of the terminal. COLOR is one of black, red, green, brown, yellow, blue, magenta, purple, cyan, white and normal. o -b, --background Set the background color o -c, --print-colors Prints a list of all valid color names o -h, --help Display help message and exit o -o, --bold Set bold or extra bright mode o -u, --underline Set underlined mode o -v, --version Display version and exit Calling set_color normal will set the terminal color to whatever is the default color of the terminal. Some terminals use the --bold escape sequence to switch to a brighter color set. On such terminals, set_color white will result in a grey font color, while set_color --bold white will result in a white font color. Not all terminal emulators support all these features. This is not a bug in set_color but a missing feature in the terminal emulator. set_color uses the terminfo database to look up how to change terminal colors on whatever terminal is in use. Some systems have old and incomplete terminfo databases, and may lack color information for terminals that support it. Download and install the latest version of ncurses and recompile fish against it in order to fix this issue. Version 1.23.1 Sun Jan 8 2012 set_color(1)
All times are GMT -4. The time now is 04:53 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy