Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google site



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

Closed Thread
English Japanese Spanish French German Portuguese Italian Powered by Powered by Google
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-17-2006
Registered User
 

Join Date: Jul 2006
Posts: 1
How to compare several files and create a new one

Hello,
I have a few files with simple data on them. All of the files may contain the same and different data. I need to create a new file that contains data that is on all files at the same time. Let say if word "ffffffff" is on all files it must be in the new file. If word "kkkkkkk" is not on all files then it must not be on the new file. Can anyone give me a solution at least for the case when there are only two files.

Thank you in advance.
Sponsored Links
  #2 (permalink)  
Old 07-18-2006
blowtorch's Avatar
AFK
 

Join Date: Dec 2004
Location: Singapore
Posts: 2,351
For two files, you can use the comm command. Use the -12 switch to supress the output of lines present in only one of the two files. You will end up with the output that is common to the two files. Like so:

Code:
# cat test1
aaa
bbb
ccc
# cat test2
aaa
bbb
ddd
# comm -12 test1 test2
aaa
bbb

Sponsored Links
Closed Thread

Bookmarks

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 Off


More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
compare files and create new with awk tonet Shell Programming and Scripting 7 12-27-2007 10:05 AM
File Compare and Create New File with Diff guiguy UNIX for Advanced & Expert Users 7 02-28-2007 06:43 AM
compare two txt files space13 Shell Programming and Scripting 8 09-22-2006 10:40 AM
help! need to compare files danielsf Shell Programming and Scripting 6 07-09-2003 06:09 PM
compare files ingunix UNIX for Dummies Questions & Answers 3 05-24-2001 12:44 PM



All times are GMT -4. The time now is 11:04 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-2010. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0