---------- Post updated at 07:12 PM ---------- Previous update was at 07:10 PM ----------
To keep the forums high quality for all users, please take the time to format your posts correctly.
First of all, use Code Tags when you post any code or data samples so others can easily read your code. You can easily do this by highlighting your code and then clicking on the # in the editing menu. (You can also type code tags [code] and [/code] by hand.)
Second, avoid adding color or different fonts and font size to your posts. Selective use of color to highlight a single word or phrase can be useful at times, but using color, in general, makes the forums harder to read, especially bright colors like red.
Third, be careful when you cut-and-paste, edit any odd characters and make sure all links are working property.
Read each line from file1 and file2 and perform <perl expression> on each line.
If the line consists of a single integer number, append it to variable x using | as a separator. The ^ is beginning of line, the $ is end of line and (\d+) represents one or more decimal digits. After your file1 example is processed, $x will equal |100|103|104|108.
If the line is not a single integer (then it will be your entries from file2), strip the first character off of variable x and save what remains in y. This is inefficient because it has to be done for each line that is processed. This places 100|103|104|108 in y. Print the line if it contains any of the strings in variable y located between two | characters.
Hi
Does anyone know of an efficient way to index a column of data in file2 to print the coresponding row in file1 which corresponds to the data in file2 AND 30 rows preceding and after the row in file1.
For example suppose you have a list of numbers in file2 (single column) as follows:... (6 Replies)
In the awk below I am trying to set/update the value of $14 in file2 in
bold, using the matching NM_ in $12 or $9 in file2
with the NM_ in $2 of file1.
The lengths of $9 and $12 can be variable but what is consistent is the start pattern
will always be NM_ and the end pattern is always ;... (2 Replies)
I am trying to use awk to find all the $2 values in file2 which is ~30MB and tab-delimited, that are between $2 and $3 in file1 which is ~2GB and tab-delimited.
I have just found out that I need to use $1 and $2 and $3 from file1 and $1 and $2of file2 must match $1 of file1 and be in the range... (6 Replies)
I want to print only the lines in file2 that match file1, in the same order as they appear in file 1
file1
file2
desired output:
I'm getting the lines to match
awk 'FNR==NR {a++}; FNR!=NR && a' file1 file2
but they are in sorted order, which is not what I want:
Can anyone... (4 Replies)
I'm trying to use awk to do the following. I have file1 with many lines, each containing 5 fields describing an individual set. I have file2 which is a template config file with variable space holders to be replaced by the values in file1. I would like to substitute each set of values in file1 with... (6 Replies)
Hello,
I have two files file 1 and file 2 each having result of a query on certain database tables and need to compare for Col1 in file1 with Col3 in file2, compare Col2 with Col4 and output the value of Col1 from File1 which is a) not present in Col3 of File2 b) value of Col2 is different from... (2 Replies)
file1:
file2:
I need to find matches for any lines in file1 that appear in file2. Desired output is '>' plus the file1 term, followed by the line after the match in file2 (so the title is a little misleading):
This is honestly beyond what I can do without spending the whole night on it, so I'm... (2 Replies)
I have file 1 & file 2 with content mentioned below. I want to get the output as shown in file3.
Requirement:
check the content of column 1 & column 2, if value of column 1 in file1 matches with first column of file2 then remaining columns(2&3) of file2 should get replaced, also if value of... (4 Replies)
I have very limited coding skills but I'm wondering if someone could help me with this. There are many threads about matching strings in two files, but I have no idea how to add a column from one file to another based on a matching string.
I'm looking to match column1 in file1 to the number... (3 Replies)
Hi All,
as you can see I'm pretty new to this board. :D
I'm struggling around with small script to search a few fields in another file.
Basically I have file1 looking like this:
15:38:28 sz:10001 pr:14.16
15:38:28 sz:10002 pr:18.41
15:38:29 sz:10003 pr:19.28
15:38:30 sz:10004... (1 Reply)