Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


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

Rep: Reputation: 0
Compare two files line by line

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, 06:30 AM   #2
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 06:48 AM.
Old 03-24-2010, 06:07 PM   #3
LQ Newbie
Registered: Mar 2010
Posts: 8

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


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 02:42 PM
Read line by line and compare learnerlearner Linux - Newbie 5 05-07-2009 11:49 AM
compare two files in C and print the line when they do not match calorie712 Programming 7 04-13-2006 02:56 AM
How do I compare files line-by-line? spiffytech Linux - Software 2 01-05-2006 03:28 PM
File reading line by line and compare Goni Linux - Software 14 09-21-2005 01:24 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:02 AM.

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