LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   List file content (https://www.linuxquestions.org/questions/linux-newbie-8/list-file-content-931000/)

ust 02-24-2012 01:39 AM

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.

corp769 02-24-2012 02:05 AM

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


All times are GMT -5. The time now is 05:23 PM.