LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 02-24-2012, 01:39 AM   #1
ust
Senior Member
 
Registered: Mar 2003
Location: fasdf
Distribution: Debian / Suse /RHEL
Posts: 1,130

Rep: Reputation: 30
List file content


I have two files as below , I would like to compare the content

file 1
======
aaa.txt
111
222
bbb.txt
333
ccc.txt
ddd.txt
eee.txt

file 2
======
aaa.txt
444
bbb.txt
555
ccc.txt
ddd.txt
eee.txt

Result
======
aaa.txt
111
222
aaa.txt
444
bbb.txt
333
bbb.txt
555
ccc.txt
ccc.txt
ddd.txt
ddd.txt
eee.txt
eee.txt

Some content is the same ( eg. aaa.txt , bbb.txt , ccc.txt , ddd.txt , eee.txt ) , I would like to list its content by a condition to a file as the above result file - if the line is the same then output its next line(s) to the result file ,

can advise what can i do ?

thanks.
 
Old 02-24-2012, 02:05 AM   #2
corp769
LQ Guru
 
Registered: Apr 2005
Posts: 5,817

Rep: Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002
Not sure what exactly you are going for at the end, but have you tried using diff and/or sort? Maybe join also.... Have a look here - http://linux.about.com/od/lts_guide/a/gdelts43.htm
 
  


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
Apply patch content embedded within a mailing list post? grahamreitz Linux - General 1 05-29-2011 12:23 PM
Dividing content of one file by content of another larspend Linux - Newbie 5 04-12-2011 08:00 PM
Script to list content of Hard Drives wildcard Linux - Software 3 08-03-2010 04:08 PM
inserting the content of a python list to a mysql database jwnjoroge Linux - Newbie 1 09-09-2009 06:51 AM
impossible to list a DAT device content's ntoughe Linux - Hardware 3 07-13-2005 09:02 AM


All times are GMT -5. The time now is 04:33 PM.

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