- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- 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
Discussions
Discussions
Forums
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
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-04-2011 03:15 AM
тАО02-04-2011 03:15 AM
Example:
file1:
this is the example.
I am working in hpux.
file2:
How to compare files?
this is the example.
If i compare file1 with file2, I should get the output as follows:
Output File:
I am working in hpux.
Please anyone help me with this.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-04-2011 03:34 AM
тАО02-04-2011 03:34 AM
Re: Comparing two files
Use diff command.
diff file1 file2.
Welcome to ITRC.
Regards
Ismail Azad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-04-2011 03:43 AM
тАО02-04-2011 03:43 AM
Re: Comparing two files
http://reality.sgiweb.org/rudy/xdiff/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-04-2011 06:42 AM
тАО02-04-2011 06:42 AM
Re: Comparing two files
Depending on what you want to do, not only 'diff' but also 'comm' and 'cmp' can be used. Read the manpages for each.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-04-2011 08:08 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-07-2011 05:26 AM
тАО02-07-2011 05:26 AM
Re: Comparing two files
Thankyou for your replies.
Both of my files have IP Addresses.
I wanted the IP address which present in file1 but not in file2 to be moved to another file. I have tried your suggestions. I didn't exactly get what I wanted.
Please help me with this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-07-2011 05:50 AM
тАО02-07-2011 05:50 AM
Re: Comparing two files
As I mentioned:
sort file1 > file1.sort
sort file2 > file2.sort
comm -23 file1.sort file2.sort > another-file
rm -f file1.sort file2.sort
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-07-2011 06:40 AM
тАО02-07-2011 06:40 AM
Re: Comparing two files
But since they are IP Addresses, that command is of no use.
I tried like that already :(
Anyways thanks a lot :)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-07-2011 06:46 AM
тАО02-07-2011 06:46 AM
Re: Comparing two files
> But since they are IP Addresses, that command is of no use.
That's not true, you just have to be sort with multiple keys using the '.' as a delimiter:
# sort -t"." -k1n,1 -k2n,2 -k3n,3 -k4n,4 file.in > file.out
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-07-2011 06:48 AM
тАО02-07-2011 06:48 AM
Re: Comparing two files
Please explain why sort(1) won't work? IP addresses are just strings. If there are problems because two IP strings are in the same equivalence class, that's another issue that's possible to solve.
Better yet, please provide an example of your two files that you want to process.