- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: comparing 2 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
12-03-2003 04:11 AM
12-03-2003 04:11 AM
I have 2 files: t1 and t2 - both of them has a list of disk devices. I intend to compare both and extract de difference. The problem is diff and comm, compare lines, and I want to compare all the differences.
Does somebody know how can I compare those files?
regards
Marcia Ferreira
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2003 04:14 AM
12-03-2003 04:14 AM
Re: comparing 2 files
Asumming that files are sorted before, both tools could do it. Else you can give us some line of both files to check format.
Regards.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2003 04:17 AM
12-03-2003 04:17 AM
Re: comparing 2 files
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2003 04:21 AM
12-03-2003 04:21 AM
Re: comparing 2 files
what do you mean by all the differences? Sort the two file as mentioned before and diff should work. Can you explain a bit more, what differences you mean?
greetings,
Michael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2003 04:27 AM
12-03-2003 04:27 AM
Re: comparing 2 files
where [len] is the length of the longest line in either file +1. The -s option tells sdiff to not display lines that are exactly alike. Differeneces in whitepspace (spaces or tabs) are counted as a valid difference.
mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2003 06:03 PM
12-03-2003 06:03 PM
Re: comparing 2 files
Considering that the file t1 and t2 has got the device names sorted by unique key ( sort -u ) and you can also use with -c option to see there are no lines with duplicate keys in addition to checking that input file is sorted and the to a diff netween them will suffice your request .
Sathish C
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2003 11:04 PM
12-03-2003 11:04 PM
Re: comparing 2 files
the problem is t1 has 26 lines, and has disks device. t1 has 27 lines and has disk device too. There are some common devices; I want to create a new file e.g t3, that will have only the different disk devices. When I use diff, comm or sdiff, they compare line to line, not line to file.
regards
Marcia
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2003 11:07 PM
12-03-2003 11:07 PM
Re: comparing 2 files
that was exactly what almost everyone sujjested to you , sort the file
sort -u t1 > t1.s
sort -u t2 > t2.s
diff t1.s t2.s
should give you the result .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2003 11:09 PM
12-03-2003 11:09 PM
Re: comparing 2 files
I'm very sorry, but comm *can* do it if files are sorted first, or you forgot to tell us something about your files. Give us some lines of both or try sort then comm.
Regards.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2003 11:12 PM
12-03-2003 11:12 PM
Re: comparing 2 files
prev=
cat t1 t2 | sort -u | while read line
do
if [ `grep -q "$line" t1 t2 | wc -l` -eq 1 ]
echo $line >> t3
fi
done
Or with awk or perl, using the sorted output of both files. But this is the simplest solution I can think of right now.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2003 11:15 PM
12-03-2003 11:15 PM
Re: comparing 2 files
(the prev= line in my solution is nonsense. Was a try that I ignored)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2003 11:18 PM
12-03-2003 11:18 PM
Re: comparing 2 files
I did sort -u first. I will send all the files to you understand what I want.
The scene is: I hae to create 2 VGs with sequencial disk devices, but I have others VG created on the server. I have to compare all the disk devices captured by ioscan, and compare with the PVs related to the VGs created. The free disk devices will use to create a new VG. (t1 is the list of a VG had created and t2 is the list of ioscan)
tks
Marcia
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2003 11:19 PM
12-03-2003 11:19 PM
Re: comparing 2 files
if you have two files like this:
# cat file1
fup1
fup2
fup3
fup4
fup5
# cat file2
fup1
fup2
fup4
fup5
fup6
# comm -3 file1 file2
fup3
fup6
Is that not what you want?
regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2003 11:22 PM
12-03-2003 11:22 PM
Re: comparing 2 files
#!/usr/bin/perl
open FILE1, "
while($i=
chomp($i);
$LIST{$i}++;
}
while($i=
chomp($i);
$LIST{$i}++
}
foreach $i (keys %LIST){
if($LIST{$i} == 1){
print "$i\n";
}
}
I am sure there are a lot quicker and more sensible ways this can be done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2003 11:24 PM
12-03-2003 11:24 PM
Re: comparing 2 files
I had never even heard of the "comm" command. Looks good to me though :)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2003 11:29 PM
12-03-2003 11:29 PM
Re: comparing 2 files
your sugestion didn´t work. If you see the attachment that I sent, you will understand why.
tks
Marc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2003 11:31 PM
12-03-2003 11:31 PM
Re: comparing 2 files
Or you could use cut to get only the device name and ignore the first 2 parts of the device path:
cut -d/ -f4
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2003 11:34 PM
12-03-2003 11:34 PM
Re: comparing 2 files
actually, I did not see your attachment before I posted. Therefore I did not understand that the issue was comparing disk devices with raw devices.
regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2003 11:43 PM
12-03-2003 11:43 PM
Solutionhow about:
# cat t1| awk -F/ '{print $4} > t1.lim
# cat t2| awk -F/ '{print $4} > t2.lim
The way it was in the detachment caused it to be $4, the idea is to have only the last parts of each line in the files. Then
# comm -3 t1.lim t2.lim
c19t0d0
c19t13d6
c19t13d7
c19t14d0
c19t14d1
c19t14d6
c19t14d7
c19t2d0
c19t3d0
c19t4d0
c19t8d0
c19t8d1
c19t8d2
c19t8d3
c21t12d0
c21t12d1
c21t12d2
c21t12d3
c21t12d4
c21t12d5
c21t12d6
c21t12d7
c21t13d0
c21t13d1
c21t13d2
c21t13d3
c21t13d4
will that do for at starting point?
regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2003 11:47 PM
12-03-2003 11:47 PM
Re: comparing 2 files
sorry, but I sent the wrong file. My partner save another file with the same name.
Your solution was right. The problem finished.
thanks a lot
Marcia
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2003 11:49 PM
12-03-2003 11:49 PM
Re: comparing 2 files
c19t8d3
and
c21t12d0
but I forgot. And I am aware that the posting looks idiotic, but try to imagine that everything before before c21t12d0 is indented and the rest is not. Believe me, it looks much better on my screen!
regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2003 11:57 PM
12-03-2003 11:57 PM
Re: comparing 2 files
cat t1 | xargs -n1 -I'{}' basename '{}' > t1.cut
cat t2 | xargs -n1 -I'{}' basename '{}' > t2.cut
diff t1 t2
greetings,
Michael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2003 12:10 AM
12-04-2003 12:10 AM
Re: comparing 2 files
best regards
Marcia Ferreira
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2003 12:30 AM
12-04-2003 12:30 AM
Re: comparing 2 files
I know you said that you solved your problem, but I thought I might offer another way in case you run into this in the future...
If I understand your problem correctly:
t1 = set of disks already in use by VG's
t2 = set of all disks on system
t3 = set of available disks = t2-t1
...right?
Here is a way (not mentioned yet) that one could solve the problem:
1. convert t1 to just the base device name
cat t1 | awk -F/ '{print $4}' | sort -u >t1.modified
2. use reverse sense "grep" to exclude from t2 what is already in t1.modified
cat t2 | grep -v -f t1.modified >t3
I tested this on your input files, and it seems to work. Good luck!
=:-) Alex
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2003 12:58 AM
12-04-2003 12:58 AM
Re: comparing 2 files
OK ... your suggestion is good too. I´ll use it in another script.
tks
Marcia Ferrei