The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
shell script for comparing 2 files prashanth.spl UNIX for Dummies Questions & Answers 2 06-20-2008 10:09 AM
comparing PID values of 2 Files in shell Options marconi Shell Programming and Scripting 2 12-19-2007 01:02 PM
How to Read config (.cfg) files using shell scripting smallwonder UNIX for Advanced & Expert Users 5 03-02-2007 12:37 AM
rename files using shell scripting gfhgfnhhn Shell Programming and Scripting 4 07-04-2006 04:37 PM
shell script comparing files in a file raina_nalin Shell Programming and Scripting 4 06-21-2005 06:00 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-30-2008
prakash123 prakash123 is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 4
Comparing two .txt files in shell scripting...

Hi,
I have two big .txt files.and i need to compare those two files and redirect it into some other file.
If any body wants to resolve this issue then i can send the two text files.
Need some quick responce.

Thanks,
prakash
  #2 (permalink)  
Old 06-30-2008
pharos467 pharos467 is offline
Registered User
  
 

Join Date: Nov 2007
Posts: 24
manual

please check "man cmp". Provide manual for compare
  #3 (permalink)  
Old 06-30-2008
sysgate's Avatar
sysgate sysgate is offline Forum Advisor  
Unix based
  
 

Join Date: Nov 2006
Location: Bulgaria
Posts: 1,322
Look at your man pages for "diff", but basically :
Code:
diff file1.txt file2.txt > someotherfile.txt
  #4 (permalink)  
Old 06-30-2008
prakash123 prakash123 is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 4
Hi,Thanks for the quick reply.In those two commands we can have the difference.But my files are very big in size and i need the comparison which will show only the difference part.for example:Test1-Hi i am prakashTest2-Hi i amThen the required shell script should show the diffrence as praksh.But the diff command will show both the files and comparison.as my files are very big the redirected file is even bigger.There fore i need a generalized shell script which will workwaiting for the response.ThanksPrakash
  #5 (permalink)  
Old 06-30-2008
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,121
look into 'man comm'
  #6 (permalink)  
Old 06-30-2008
awk awk is offline
Registered User
  
 

Join Date: Feb 2007
Posts: 134
AIX and HP-UX have
Code:
bdiff
.
  #7 (permalink)  
Old 06-30-2008
WebKruncher WebKruncher is offline VIP Member  
VIP Member
  
 

Join Date: Dec 2007
Location: Simi Valley, CA
Posts: 29
FileKruncher

There are so many ways to skin this cat, but my favorite is the stl. If you use two custom streams, and tweak your buffers to the rightt size, you can do just about any kind of file comparison you can imagine, and get pretty good speed out of it.
I have a sample if you're interested. Here's an example of the streams (not completely tested).

WebKruncher.com/speedstreams.h - It's used like any typical file streams, just create and call getline 'till eof or read in chunks for a binary comparisons.
-Jmt
Closed Thread

Bookmarks

Tags
linux, solaris

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 04:33 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0