Is ok you don't have sample but knowing they are both csv just with different column we can use like:
NR is record number, by default a record is a line. FNR is file record number, thus, for the first file the two are the same. When file2 is opened, NR keeps incrementing, but FNR resets. So they are equal for file1 and we put the 5th field into associative array. So a[workorder#] is counting them... Then the expression is a[$3] for file2, to see if that key exists from file1 and the default action is to print the line...
So hopefully you only need to change the 5 and 3 for this to work.
hello,
I go text file like this
E:/DDD/Dyndede/wwww
E:/DDD/sss.com/ffffg/fff
E:/DDD/vvvvvv/dd
E:/DDD/sss.com/bbbbbb
E:/DDD/sss.com/nnnn/xxI want to print
/alpha.jpg at the end of every lines like that
E:/DDD/Dyndede/wwww/alpha.jpg
E:/DDD/sss.com/ffffg/fff/alpha.jpg... (8 Replies)
Hello,
I am strugling from quite a some time to compare flat files with over 1 million records could anyone please help me.
I want to compare two pipe delimited flat files, file1 with file2 and output the unmatched rows from file2 in file3
Sample File1:
... (9 Replies)
I have a command which prints #lines after and before the search string in the huge file
nawk 'c-->0;$0~s{if(b)for(c=b+1;c>1;c--)print r;print;c=a}b{r=$0}' b=0 a=10 s="STRING1" FILE
The file is 5 gig big.
It works great and prints 10 lines after the lines which contains search string in... (8 Replies)
Hello. I have two files. FILE1 was extracted from FILE2 and modified thanks to help from this post. Now I need to replace the extracted, modified lines into the original file (FILE2) to produce the FILE3.
FILE1
1466 55.27433 14.72050 -2.52E+03 3.00E-01 1.05E+04 2.57E+04
1467 55.27433... (1 Reply)
Hi,
I have a file with contents
test id text day
test sah dh dhs
yeay fg jsh jsjk
my need:
I give a string as a input, it check the file and display the lines with the given string
e.g
input : test
output:
test id text day
test sah dh dhs (1 Reply)
Hi,
I have multiple files that each contain one column of strings:
File1:
123abc
456def
789ghi
File2:
123abc
456def
891jkl
File3:
234mno
123abc
456def
In total I have 25 of these type of file. (5 Replies)
Hi,
I want to compare two columns from file1 with another two column of file2 and print matched and unmatched column like this
File1
1 rs1 abc
3 rs4 xyz
1 rs3 stu
File2
1 kkk rs1 AA 10
1 aaa rs2 DD 20
1 ccc ... (2 Replies)
HI,
I have 2 text files. file1 and file2.
file1.txt (There are no duplicates in this file)
1234
3232
4343
3435
6564
6767
1213
file2.txt
1234,wq,wewe,qwqw
1234,as,dfdf,dfdf
4343,asas,sdds,dsds
6767,asas,fdfd,fdffd
I need to search each number in file1.txt in file2.txt's 1st... (6 Replies)
Discussion started by: Little
6 Replies
LEARN ABOUT OSF1
sdiff
sdiff(1) General Commands Manual sdiff(1)NAME
sdiff - Compares two files and displays the differences in a side-by-side format
SYNOPSIS
sdiff [-l | -s] [-w number] [-o output_file] file1 file2
The sdiff command reads file1 and file2, uses diff to compare them, and writes the results to standard output in a side-by-side format.
OPTIONS
Displays only the left side when lines are identical. Creates a third file, output_file, by a controlled interactive line-by-line merging
of file1 and file2. The following subcommands govern the creation of this file: Adds the left side to output_file. Adds the right side to
output_file. Stops displaying identical lines. Begins displaying identical lines. Enters ed with the left side, the right side, both
sides, or an empty file, respectively.
Each time you exit from ed, sdiff writes the resulting edited file to the end of output_file. If you fail to save the changes
before exiting, sdiff writes the initial input to output_file. Exits the interactive session. Suppresses display of identical
lines. Sets the width of the output line to number (130 characters by default).
DESCRIPTION
The sdiff command displays each line of the two files with a series of spaces between them if the lines are identical, a < (left angle
bracket) in the field of spaces if the line only exists in file1, a > (right angle bracket) if the line only exists in file2, and a | (ver-
tical bar) for lines that are different.
When you specify the -o option, sdiff produces a third file by merging file1 and file2 according to your instructions.
Note that the sdiff command invokes the diff -b command to compare two input files. The -b option causes the diff command to ignore trail-
ing spaces, tab characters, and consider other strings of spaces as equal.
EXAMPLES
To print a comparison of two files, enter: sdiff chap1.bak chap1
This displays a side-by-side listing that compares each line of chap1.bak and chap1. To display only the lines that differ, enter:
sdiff -s-w 80 chap1.bak chap1
This displays the differences at the tty. The -w 80 sets page width to 80 columns. The -s option tells sdiff not to display lines
that are identical in both files. To selectively combine parts of two files, enter: sdiff -s-w 80 -o chap1.combo chap1.bak
chap1
This combines chap1.bak and chap1 into a new file called chap1.combo. For each group of differing lines, sdiff asks you which group
to keep or whether you want to edit them using ed.
SEE ALSO
Commands: diff(1), ed(1)sdiff(1)