How to Remove duplicate value from file?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to Remove duplicate value from file?
# 8  
Old 02-18-2013
Quote:
Originally Posted by zazzybob
As long as you specify the correct path to your input file in the file variable in the script, it should work. In the example below the input file is foo.txt and it exists in the same directory as foo.sh, which is also your present working directory.

i have checked everything ....file ar also reading but output is no showing please can u give query for writing output in file......because this is the output what i need .....so please
# 9  
Old 02-18-2013
Just redirect the output to a file.

Code:
$ ./foo.sh > foo.output

Not sure what you mean by "file ar also reading but output is no showing". The script generates output for me.
# 10  
Old 02-19-2013
Hi zazzybob,
if input file is like following then..
Code:
BI	M	IT056868	UNICREDI	VIA	LIBHIA	UNCRIT2B	XXX	UNCR	UNCRIT2B	XXX	UNCR
BI	M	US001165	NEUBERGE	LLC	NEWYRK	NEUBUS33	XXX	NEUB
HH	M	IND90909	SBILIFES	HNI	NANANN	GGGGGGGG		UICC
HH	M	MNOOOOwO	98989089	IIC	UMNKSS	MOHAN844	XXX	KLKL	MOHAN844	XXX
HH	M	IND90909	SBILIFES	HNI	NANAAN	MSSSMSSM	123	UIHH	MSSSMSSM	123
HH	M	IND90909	SBILIFES	HNI	NAANAN	MSSSMSSM	234	UIHH
HH	M	IND90909	SBILIFES	HNI	NANANA	MSSSMSSM	543	UIHH
BI	M	ES063710	CAJAMEDI	TER	RANEOR	BCOEESMM	821	BCOEESMM	XXX	BCOE	ES	
BI	M	ES063711	CAJARURA	DEL	MEDITE	BCOEESMM	821	BCOEESMM	XXX	BCOE	ES	
BI	M	ES063777	CAJARURA	DEL MEDITE	BCOEESMM	821	BCOEESMM	XXX			BC
BI	M	ES063838	CAJARURA	DEL MEDITE	BCOEESMM	821	BCOEESMM	XXX			BC
BI	M	ES063838	CAJARURA	DEL MEDITE	BCOEESMM	XXX	BCOEESMM	XXX			BC

and i want same output what i explained above...and if $7 value is duplicate and $8 value is also XXX of both value of $7.then i want only one row no other duplicate value..

Last edited by Franklin52; 02-19-2013 at 07:39 AM.. Reason: Please use code tags for data and code samples
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Remove duplicate values in a column(not in the file)

Hi Gurus, I have a file(weblog) as below abc|xyz|123|agentcode=sample code abcdeeess,agentcode=sample code abcdeeess,agentcode=sample code abcdeeess|agentadd=abcd stereet 23343,agentadd=abcd stereet 23343 sss|wwq|999|agentcode=sample1 code wqwdeeess,gentcode=sample1 code... (4 Replies)
Discussion started by: ratheeshjulk
4 Replies

2. Shell Programming and Scripting

Remove duplicate lines from a file

Hi, I have a csv file which contains some millions of lines in it. The first line(Header) repeats at every 50000th line. I want to remove all the duplicate headers from the second occurance(should not remove the first line). I don't want to use any pattern from the Header as I have some... (7 Replies)
Discussion started by: sudhakar T
7 Replies

3. Shell Programming and Scripting

Remove the duplicate content in a file

Here is the contents of test.txt Dependencies Resolved Changes in packages about to be updated: ChangeLog for: 1:perl-Archive-Extract-0.38-131.el6_4.x86_64, - Resolves: #915692 - CVE-2013-1667 (DoS in rehashing code) Dependencies Resolved Changes in packages about to be updated: ... (5 Replies)
Discussion started by: ashokvpp
5 Replies

4. Shell Programming and Scripting

How do I remove the duplicate lines in this file?

Hey guys, need some help to fix this script. I am trying to remove all the duplicate lines in this file. I wrote the following script, but does not work. What is the problem? The output file should only contain five lines: Later! (5 Replies)
Discussion started by: Ernst
5 Replies

5. Shell Programming and Scripting

remove of duplicate line from a file

I have a file a.txt having content like deepak ram sham deepram sita kumar I Want to delete the first line containing "deep" ... I tried using... grep -i 'deep' a.txt It gives me 2 rows...I want to delete the first one.. + need to know the command to delete the line from... (5 Replies)
Discussion started by: saluja.deepak
5 Replies

6. Shell Programming and Scripting

Formatting a file - Remove Duplicate

Hi I have a file in the following format. Basically the file contains tablename and their aliases: TABLE1 TABLE1 A TABLE2 TABLE2 B TABLE3 TABLE4 TABLE4 C TABLE4 Upon formatting an sql statement I am getting such output. Problem: Whenever a tablename appears with alias, it has... (5 Replies)
Discussion started by: freakygs
5 Replies

7. Shell Programming and Scripting

Sort and Remove Duplicate on file

How do we sort and remove duplicate on column 1,2 retaining the record with maximum date (in feild 3) for the file with following format. aaa|1234|2010-12-31 aaa|1234|2010-11-10 bbb|345|2011-01-01 ccc|346|2011-02-01 bbb|345|2011-03-10 aaa|1234|2010-01-01 Required Output ... (5 Replies)
Discussion started by: mabarif16
5 Replies

8. UNIX for Dummies Questions & Answers

Remove Duplicate lines from File

I have a log file "logreport" that contains several lines as seen below: 04:20:00 /usr/lib/snmp/snmpdx: Agent snmpd appeared dead but responded to ping 06:38:08 /usr/lib/snmp/snmpdx: Agent snmpd appeared dead but responded to ping 07:11:05 /usr/lib/snmp/snmpdx: Agent snmpd appeared dead but... (18 Replies)
Discussion started by: Nysif Steve
18 Replies

9. Shell Programming and Scripting

Remove Duplicate Lines in File

I am doing KSH script to remove duplicate lines in a file. Let say the file has format below. FileA 1253-6856 3101-4011 1827-1356 1822-1157 1822-1157 1000-1410 1000-1410 1822-1231 1822-1231 3101-4011 1822-1157 1822-1231 and I want to simply it with no duplicate line as file... (5 Replies)
Discussion started by: Teh Tiack Ein
5 Replies
Login or Register to Ask a Question