The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How do I delete a data string from a .dat file in unix supergirl3954 UNIX for Dummies Questions & Answers 4 03-04-2008 04:56 AM
edit, and delete data from you file dorek High Level Programming 1 06-22-2006 07:09 PM
Script to delete all data from multiple files uni_ajay_r Shell Programming and Scripting 5 03-29-2006 08:05 AM
Delete blocks with no data.. mgirinath Shell Programming and Scripting 1 01-28-2006 03:33 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 07-15-2006
Registered User
 

Join Date: Jul 2006
Posts: 16
Delete unmatched data

Hi,

I try to write script to compare 2 data file (list of numbers) which after that I want to delete unmatched numbers and create new file for matched numbers.

Can anybody to help me?
Reply With Quote
Forum Sponsor
  #2  
Old 07-15-2006
tayyabq8's Avatar
Moderator
 

Join Date: Nov 2004
Location: Bahrain
Posts: 555
could you pls post some sample data from these 2 files?
Reply With Quote
  #3  
Old 07-15-2006
Registered User
 

Join Date: Jul 2006
Posts: 16
Hi,

The sample data as below;

File 1 (number1.csv):
1
2
3
4
5
6
7
8
9

File 2 (number2.csav):
1
3
5
9


-nazri76-
Reply With Quote
  #4  
Old 07-15-2006
tayyabq8's Avatar
Moderator
 

Join Date: Nov 2004
Location: Bahrain
Posts: 555
I hope this is not homework.
In your case, where file is already sorted:
Code:
comm -12  file1 file2 > file3
Reply With Quote
  #5  
Old 07-15-2006
Registered User
 

Join Date: Jul 2006
Posts: 16
Thankss!!! But if the file no sorted, is it i need to sort it first?

No, this is not homework, but something that i need to do everyday.

-nazri76-
Reply With Quote
  #6  
Old 07-16-2006
blowtorch's Avatar
Supporter
 
Join Date: Dec 2004
Location: Singapore
Posts: 2,326
Quote:
Originally Posted by nazri76
Thankss!!! But if the file no sorted, is it i need to sort it first?
Yes. Check the man page of comm here for more.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 11:42 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0