LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-24-2010, 05:21 AM   #1
si-thk
LQ Newbie
 
Registered: Mar 2010
Posts: 8

Rep: Reputation: 0
Compare two files line by line


Hi,
I have two files (not sorted) and need to compare line by line (i.e. first line of file1 to be compared to all the lines of file2 and so as for the rest of file1). Output will be an array of length of file2. Any suggestion in BASH other than a grep inside two read line loops ( which is time consuming for files ~1000s of lines) is much appreciated.

Thanks in advance.
 
Old 03-24-2010, 05:30 AM   #2
rizhun
Member
 
Registered: Jun 2005
Location: England
Distribution: Ubuntu, SLES, AIX
Posts: 268

Rep: Reputation: 47
Awk or Perl should be much faster than 'grep'.

Have a look at this link.

Last edited by rizhun; 03-24-2010 at 05:48 AM.
 
Old 03-24-2010, 05:07 PM   #3
si-thk
LQ Newbie
 
Registered: Mar 2010
Posts: 8

Original Poster
Rep: Reputation: 0
Thanks for the link. I will look into it.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
BASH: read every line in the files and use the line as parameters as another program tam3c36 Programming 10 12-07-2010 01:42 PM
Read line by line and compare learnerlearner Linux - Newbie 5 05-07-2009 10:49 AM
compare two files in C and print the line when they do not match calorie712 Programming 7 04-13-2006 01:56 AM
How do I compare files line-by-line? spiffytech Linux - Software 2 01-05-2006 02:28 PM
File reading line by line and compare Goni Linux - Software 14 09-21-2005 12:24 AM


All times are GMT -5. The time now is 12:37 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration