Help regarding effective usage of diff for comparing files
Help regarding effective usage of diff for comparing files
Hi All,
I have few doubts regarding best usage of diff command. I also have some questions with out put of diff command.
File1:
ABC
DEF
File2:
ABC
DEFAA
QUESTION:
What does this 2c2 signifies. I also see some times it as 2d5, i have googled regarding this but couldn't found any information regarding this. If some one can please tell me what it signifies, that will be of great help, preferably if some link to study this.
COMING TO MY MAIN PROBLEM:
Problem statement:
I want to dump non common lines when two files are diffed to new files. In case of above example two files should be generated
i.e. file1_new and file2_new that contains only "DEF" and "DEFAA" only (lines which are not common).
I also want to maintain the line number (original) of these files to be dumped in new files.
Thanks in advance,
Sarbjit
Last edited by sarbjit; 05-21-2011 at 03:18 AM..
Reason: code tags...
I want to dump non common lines when two files are diffed to new files. In case of above example two files should be generated
i.e. file1_new and file2_new that contains only "DEF" and "DEFAA" only (lines which are not common).
I also want to maintain the line number (original) of these files to be dumped in new files.
Sorry I don't think that the "diff" command is suitable. The output of "diff" gives lines in context and will therefore output some lines which are not different. It also does not number the lines.
The requirement for the line number eliminates every unix utility I can think of.
We'd certainly need to be sure that these are unix format text files and know a lot more about the data structure. Programs to process differences are really only effective on sorted files which do not contain large numbers of identical data.
In this case sorting the data would appear to be out of the question because you want to maintain the order of the data.
Hi all,
I have 2 directories on two different servers. I am trying to find out what is missing from directory X and what is missing from directory Y. they should both have the same exact files in them.
I understand some files may be missing from both directories on each server. I am not sure... (8 Replies)
Guys i have 3 files,
but i want to compare and diff only the 2nd column
path=`/home/whois/doms`
for i in `cat domain.tx`
do
whois $i| sed -n '/Registry Registrant ID:/,/Registrant Email:/p' > $path/$i.registrant
whois $i| sed -n '/Registry Admin ID:/,/Admin Email:/p' > $path/$i.admin... (10 Replies)
Greetings.
I like to compare two lists of numbers, A.txt and B.txt, to see the numbers that are in B.txt but not in A.txt. I only need the "deletions" with reference to A.txt. Using the diff command doesn't work because it considers too many of the deletions just changes because they are a... (7 Replies)
Hi All,
I have two files which look as below
File1
serial="1" name="abc" type="employee" field="IT"
serial="2" name="cde" type="intern" field="Marketing"
serial="3" name="pqr" type="contractor" field="IT"
serial="4" name="xyz" type="employee" field="Sales"
File2
serial="1"... (3 Replies)
Hi Masters,
I have two files named file1 and file2.
Both the files contains the same contents with some difference in comments,space.But no content change.
I tried to find the diff between the two files to make sure that contents are same.
For that i tried
diff -ibw file1 file2
But... (1 Reply)
We are working in the office where about 5-6 machines have Internet access. We pay for each GB of traffic we consume and that's quite expensive. Almost no worker download files. Just surfing websites (including our corporate one that is located outside of local network thus we pay for accessing it... (5 Replies)
how can I find cpu usage memory usage swap usage and
I want to know CPU usage above X% and contiue Y times and memory usage above X % and contiue Y times
my final destination is monitor process
logical volume usage above X % and number of Logical voluage above
can I not to... (3 Replies)
I need to compare 2 diff type of files and find out the duplicate after comparing each types of files:
Type 1 file name is like: file1.abc
(the extension abc could any 3 characters but I can narrow it down or hardcode for 10/15 combinations).
The other file is file1.bcd01abc (the extension... (2 Replies)
Hello,
I want to compare two files. All records in file 2 that are not in file 1 should be output to file 3.
For example:
file 1
123
1234
123456
file 2
123
2345
23456
file 3 should have
2345
23456
I have looked at diff, bdiff, cmp, comm, diff3 without any luck! (2 Replies)