The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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



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 !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
compare 2 files.. amon Shell Programming and Scripting 8 06-23-2008 10:34 AM
compare two files charandevu Shell Programming and Scripting 7 03-30-2008 03:20 PM
Compare files kharen11 UNIX for Advanced & Expert Users 25 03-14-2007 05:35 AM
compare files and beyond MizzGail UNIX for Dummies Questions & Answers 2 04-25-2003 01:34 PM
compare files ingunix UNIX for Dummies Questions & Answers 3 05-24-2001 11:44 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-15-2001
b5fnpct b5fnpct is offline
Registered User
  
 

Join Date: Aug 2001
Posts: 15
Talking Compare two files

Hi,

There are two files with some lines are exactly the same, some lines are not. I want to compare these two files and create a third file contains both the first and second file's lines without duplicate line. Which command should I use? If I write a shell script, what is the syntax to "open" a file instead of using "cat"?

Thanks in advance!

  #2 (permalink)  
Old 08-15-2001
PxT's Avatar
PxT PxT is offline Forum Advisor  
Registered User
  
 

Join Date: Oct 2000
Location: Sacramento, CA
Posts: 909
Code:
cat file1 file2 | sort | uniq > file3
  #3 (permalink)  
Old 08-16-2001
PxT's Avatar
PxT PxT is offline Forum Advisor  
Registered User
  
 

Join Date: Oct 2000
Location: Sacramento, CA
Posts: 909
Gotta slap myself with a UUOC for that one.

Better solution:
Code:
sort file1 file2 | uniq > file3
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 On




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

Content Relevant URLs by vBSEO 3.2.0