Delete unmatched data


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Delete unmatched data
# 1  
Old 07-16-2006
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?
# 2  
Old 07-16-2006
could you pls post some sample data from these 2 files?
# 3  
Old 07-16-2006
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-
# 4  
Old 07-16-2006
I hope this is not homework.
In your case, where file is already sorted:
Code:
comm -12  file1 file2 > file3

# 5  
Old 07-16-2006
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. Smilie

-nazri76-
# 6  
Old 07-16-2006
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.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Delete incomplete data

Hi all, Please help with the following example. I want to keep all people in the data, who at least have Firstname or Lastname or both and at least 1 row of Details. So, Person4 lacking both Firstname and Lastname will be deleted, Person5 with no Details will be deleted. Firstname,Lastname... (3 Replies)
Discussion started by: ritakadm
3 Replies

2. Shell Programming and Scripting

How to delete lines having unmatched delimeters in a file?

Hi, I have a delimited (|) file having millions of rows. Sometime the file comes with less number of delimiters than expected. In this scenario I want to delete the row having unmatched delimiters. Can anyone help me with the command to achieve this? Ex: File1.txt 8039339595113|JIMMY... (2 Replies)
Discussion started by: satyaatcgi
2 Replies

3. Shell Programming and Scripting

Unmatched <<

Hi, I am running sinple ksh script . From some reason it failed on the following error: ./ogg_status.sh: syntax error at line 16 : `<<' unmatched Please advise. #!/usr/bin/ksh export ORACLE_HOME=/software/oracle/DB10gR2 export LD_LIBRARY_PATH=/software/oracle/DB10gR2/lib:/usr/lib... (4 Replies)
Discussion started by: yoavbe
4 Replies

4. UNIX for Dummies Questions & Answers

Mapping a data in a file and delete line in source file if data does not exist.

Hi Guys, Please help me with my problem here: I have a source file: 1212 23232 343434 ASAS1 4 3212 23232 343434 ASAS2 4 3234 23232 343434 QWQW1 4 1134 23232 343434 QWQW2 4 3212 23232 343434 QWQW3 4 and a mapping... (4 Replies)
Discussion started by: kokoro
4 Replies

5. Shell Programming and Scripting

Delete data between [] with sed

i'm cat /var/log/message Jan 10 14:48:45 LOG SKYPE-OUT IN=eth1 OUT=eth2 SRC=192.168.1.65 DST=203.157.168.5 PROTO=TCP SPT=1284 DPT=3306 Jan 10 14:48:45 LOG HTTPS IN=eth0 OUT=eth1 SRC=207.46.15.251 DST=192.168.1.47 PROTO=TCP SPT=443 DPT=2069 Jan 10 14:48:45 LOG HTTPS IN=eth0 OUT=eth1... (2 Replies)
Discussion started by: slackman
2 Replies

6. Shell Programming and Scripting

print unmatched data from 2 files

Hi, i need help to extract unmatched data from 2 files. for instance, the input file like below: file1.txt ID hit addhit 123 sp q9876 656 sp q5641 332 sp d1211 248 sp f5642file2.txt ID Num def activity 123 447 trial ... (4 Replies)
Discussion started by: redse171
4 Replies

7. Shell Programming and Scripting

Delete duplicate data and pertain the latest month data.

Hi I have a file with following records It contains three months of data, some data is duplicated,i need to access the latest data from the duplicate ones. for e.g; i have foll data "200","0","","11722","-63","","","","11722","JUL","09" "200","0","","11722","-63","","","","11722","JUL","09"... (10 Replies)
Discussion started by: vee_789
10 Replies

8. Shell Programming and Scripting

`for' unmatched

:b:Hi guys, I am getting this error in this piece of code, Any help will be appreciate rypidoc.shl: syntax error at line 79 : `for' unmatched ##Determine if there is a file to process ls 3526*.dat > /dev/null 2>&1 if then exit fi for i in 3526*.dat do # Capture just the file... (2 Replies)
Discussion started by: rechever
2 Replies

9. Shell Programming and Scripting

else unmatched

I'm getting an else unmatched error on the script below.. For info : SYDB is the database name entered as a param on the command line. #Check the DB name HBDB=`sql $SYDB <<_END_ | grep '^|' | grep -v dbase | sed 's/|//g' | sed 's/ //g' set autocommit on; \p\g set lockmode... (7 Replies)
Discussion started by: b.hamilton
7 Replies

10. Shell Programming and Scripting

Delete blocks with no data..

Hi, I tried this but could not get it... here is what I need I have an xml where I get all the data in blocks but some times I get empty blocks with no data...shown below..I need to delete only those blocks with no data, I tried couple of ways but could not do it..any help is appreciated...... (1 Reply)
Discussion started by: mgirinath
1 Replies
Login or Register to Ask a Question