11-21-2008
awk command to comapre two files
if u have two files
first file and second file
awk command will be
awk 'BEGIN {while (getline <"first file") {arr[$0]++}}
{ if (!($0 in arr) {print }}' second file
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I have a file named file1 which contains numbers in sequence like...
1
2
3
7
8
Then i have file File 2 that contains
4
5
........so i need to compare both files so that i can find out the missing entry in the sequence is 6.......These files are flat files which contain and so i need to... (5 Replies)
Discussion started by: coolguy01
5 Replies
2. Shell Programming and Scripting
Hi,
I have written a script which would FTP a dump file to the FTP server and log the whole activity into a file. to confirm the success of the file copy i grep for "226 file receive OK" and then send out an email saying success. Now i want to make sure the bytes of the local file and... (4 Replies)
Discussion started by: dba.admin2008
4 Replies
3. Shell Programming and Scripting
HI,
I would like to know how to compare two files and replace non-matching lines with "_" .
I can get non-mathing lines with
grep -v -f file1 file2
i just want to knw how to display 'file2' with non-matching lines from 'file1' replaced by "_"
for exmaple
file1:
a
b
c
d
... (2 Replies)
Discussion started by: maddy81
2 Replies
4. Shell Programming and Scripting
Hi All,
I have thefollowing files in the directory inbox/sat
ras.sat.trn.20090103.001902.00004358
ras.sat.trn.20090612.001903.00005339
ras.sat.trn.20090723.001902.00004358
The above file contains the date of the file creation. We just need to write a ksh shell script to check the... (5 Replies)
Discussion started by: satheesh_color
5 Replies
5. Shell Programming and Scripting
Hi All
I have to files
cat a.txt
AAA
BBB
CCC
DDD
and
cat b.txt
AAA
CCC
EEE
i want to compare these two files and o/p should have content of file a.txt which is not in file b.txt
c.txt
BBB
DDD
Please help me (1 Reply)
Discussion started by: aaysa123
1 Replies
6. Shell Programming and Scripting
Hi All
I have to files
cat a.txt
AAA
BBB
CCC
DDD
and
cat b.txt
AAA
CCC
EEE
i want to compare these two files and o/p should have content of file a.txt which is not in file b.txt
c.txt
BBB
DDD
Please help me (3 Replies)
Discussion started by: aaysa123
3 Replies
7. Shell Programming and Scripting
Hi,
I am trying to find an alternative way to do tkdiff. In tkdiff the gui compares each line and highlights only the differences.
for eg:
John works at McDonalds s(test)
He was playing guitar tywejk
John works in McDonalds 9908
He was playing guitar
I am... (1 Reply)
Discussion started by: naveen@
1 Replies
8. Shell Programming and Scripting
Hi All,
I want to write a script which will compare two files and tell me if the files are different.
Actually my files will be same but order of lines will be different,so diff is not working.
I have written a script to do this:-
while read line; do
cnt=`grep -i $line... (6 Replies)
Discussion started by: prasson_ibm
6 Replies
9. Shell Programming and Scripting
Hi everybody,
First I apologize if my question seems demasiad you silly, but it really took 4 days struggling with this, I looked at books, forums ... And Also ask help to a friend that is software developer and he told me that it is a bad idea do it by perl... but this is my problem.
I moved to... (8 Replies)
Discussion started by: Thelost
8 Replies
10. Shell Programming and Scripting
Hi,
I want to compare 2 files and get output file into seperate folder.
Both file names will change daily with timestamp (ex: file1_06_17_2013_0514), so i can't mention the file names in the script to compare,
but i need to compare these 2 files daily and generate output to another... (28 Replies)
Discussion started by: rkrish123
28 Replies