- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: commands for comparing two files ..
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2011 12:52 PM
02-11-2011 12:52 PM
I have to compare two files .. i used diff
diff -Cn file1 file 2
i see this sign "!" what does that mean?
what other command could help me to compare two files? in theory they should have the same information so i have to see why they are different .. the information are paths ..
please your help
thanks.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2011 01:05 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2011 01:18 PM
02-11-2011 01:18 PM
Re: commands for comparing two files ..
As mentioned above, it is difficult to provide you with an exact answer without the actual diff output.
Nevertheless, a "!" represents a change between lines that correspond in the two files.
See: http://en.wikipedia.org/wiki/Diff
sangilak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2011 01:26 PM
02-11-2011 01:26 PM
Re: commands for comparing two files ..
The '!' notation means that the line is *not* present. Just as you use '!' to negate an expression...
Using the '-C' or '-c' offers differences in context.
Look at the manpages and the files you are comparing.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2011 03:57 PM
02-11-2011 03:57 PM
Re: commands for comparing two files ..
grep -vf file1 file2
i think it is easier than diff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2011 04:20 PM
02-11-2011 04:20 PM
Re: commands for comparing two files ..
> grep -vf file1 file2
> i think it is easier than diff
Depending on your objective (and whether or not the files are sorted or not and/or have meaningful sequences of lines, suggests things like 'grep', 'diff', 'comm', or a bit of my favorite (Perl) come to mind for file "comparisons".
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2011 05:12 PM
02-11-2011 05:12 PM
Re: commands for comparing two files ..
I would add that 'diff' has a larger value than merely reporting the differences in two files. The output of 'diff' can be used to create file2 from file1 using either 'ed(1)' or 'patch(1)'.
Have a look at the manpages for 'diff(1)' and for 'patch(1)' for more insight.
As a bit of UNIX history trivia, the original author of the 'patch' utility was one Larry Wall --- who later invented the the Perl language and who continues to shepard its evolution (with many others) today.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2011 07:54 PM
02-11-2011 07:54 PM
Re: commands for comparing two files ..
I have file "a"
cuatro
diez
dos
n
och
seis
siete
tres
uno
I have file "b"cinco
cuat
dos
nueve
t
tres
1.- i want to have the output which shows me the lines that I do not have in the file b being compared with file a, this will be the output i want to get through commands coded:
cuatro
diez
n
och
seis
siete
uno
2.- i want to have the output which shows me what words i do not have neither file a nor file b, it will be:
cuatro
diez
n
och
seis
siete
uno
cinco
cuat
nueve
t
please your support.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2011 08:21 PM
02-11-2011 08:21 PM
Re: commands for comparing two files ..
=====================
EJEMPLO
=========================
$ cat a
cuatro
diez
dos
n
och
seis
siete
tres
uno
$
$ cat b
cinco
cuat
dos
nueve
t
tres
I need to know what i have i "a" and not in "b"
$ comm -23 a b
cuatro
diez
n
och
seis
siete
uno
is this correct? i think yes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2011 10:33 AM
02-12-2011 10:33 AM
Re: commands for comparing two files ..
> I need to know what i have i "a" and not in "b"
You are correct. Since your files are sorted:
# comm -23 a b
That is, show all lines that appear in 'a' but not in 'b'.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2011 08:38 PM
02-13-2011 08:38 PM
Re: commands for comparing two files ..
# diff file1 file2
another way
# grep -vf file1 file2
Regards,
INH
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2011 03:40 AM
02-14-2011 03:40 AM
Re: commands for comparing two files ..
>grep -vf file1 file2
The problem with the first is the extra metadata being output.
The second has N*N compares vs just N. Of course you do have to sort both files.