<?xml version="1.0" encoding="UTF-8"?><rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
> <channel><title>Comments on: Shell: How To Remove Duplicate Text Lines</title> <atom:link href="http://www.cyberciti.biz/faq/unix-linux-shell-removing-duplicate-lines/feed/" rel="self" type="application/rss+xml" /><link>http://www.cyberciti.biz/faq/unix-linux-shell-removing-duplicate-lines/</link> <description>Every answer asks a more beautiful question.</description> <lastBuildDate>Fri, 10 Feb 2012 19:55:56 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <item><title>By: Rakesh</title><link>http://www.cyberciti.biz/faq/unix-linux-shell-removing-duplicate-lines/#comment-61638</link> <dc:creator>Rakesh</dc:creator> <pubDate>Wed, 17 Aug 2011 17:01:36 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=1815#comment-61638</guid> <description>Rows means dupliacte text data is comma seperated
example:
this,1,country,567,1,1,1,1
that,2,country,678,2,2,2,2
this,1,country,567,3,3,3,3
from the above data, it shoulb be check for duplicate data upto 4 values(this,1,country,567) and also redirect the particular duplicate lines into some another fil, pls help me..................</description> <content:encoded><![CDATA[<p>Rows means dupliacte text data is comma seperated<br
/> example:<br
/> this,1,country,567,1,1,1,1<br
/> that,2,country,678,2,2,2,2<br
/> this,1,country,567,3,3,3,3</p><p>from the above data, it shoulb be check for duplicate data upto 4 values(this,1,country,567) and also redirect the particular duplicate lines into some another fil, pls help me&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;</p> ]]></content:encoded> </item> <item><title>By: Rakesh</title><link>http://www.cyberciti.biz/faq/unix-linux-shell-removing-duplicate-lines/#comment-61637</link> <dc:creator>Rakesh</dc:creator> <pubDate>Wed, 17 Aug 2011 16:56:25 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=1815#comment-61637</guid> <description>I want to redirect only duplicate rows into another file, anyone help me pls?</description> <content:encoded><![CDATA[<p>I want to redirect only duplicate rows into another file, anyone help me pls?</p> ]]></content:encoded> </item> <item><title>By: web designing chennai</title><link>http://www.cyberciti.biz/faq/unix-linux-shell-removing-duplicate-lines/#comment-61466</link> <dc:creator>web designing chennai</dc:creator> <pubDate>Thu, 11 Aug 2011 04:58:41 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=1815#comment-61466</guid> <description>Thanks and it helped me a lot.</description> <content:encoded><![CDATA[<p>Thanks and it helped me a lot.</p> ]]></content:encoded> </item> <item><title>By: Pranab Rana</title><link>http://www.cyberciti.biz/faq/unix-linux-shell-removing-duplicate-lines/#comment-59823</link> <dc:creator>Pranab Rana</dc:creator> <pubDate>Mon, 06 Jun 2011 12:20:39 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=1815#comment-59823</guid> <description>Thanks  for this  post.</description> <content:encoded><![CDATA[<p>Thanks  for this  post.</p> ]]></content:encoded> </item> <item><title>By: stacy</title><link>http://www.cyberciti.biz/faq/unix-linux-shell-removing-duplicate-lines/#comment-50412</link> <dc:creator>stacy</dc:creator> <pubDate>Thu, 28 Oct 2010 01:27:31 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=1815#comment-50412</guid> <description>just pipe the output to a new filename:
sort abc.txt &#124; uniq &gt; abc_1.txt</description> <content:encoded><![CDATA[<p>just pipe the output to a new filename:</p><p>sort abc.txt | uniq &gt; abc_1.txt</p> ]]></content:encoded> </item> <item><title>By: stacy</title><link>http://www.cyberciti.biz/faq/unix-linux-shell-removing-duplicate-lines/#comment-50411</link> <dc:creator>stacy</dc:creator> <pubDate>Thu, 28 Oct 2010 01:24:29 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=1815#comment-50411</guid> <description>Also i needed both files so my command was more like this:
sort garbage.file &#124; uniq &gt; garbage_no_duplicates.file</description> <content:encoded><![CDATA[<p>Also i needed both files so my command was more like this:</p><p>sort garbage.file | uniq &gt; garbage_no_duplicates.file</p> ]]></content:encoded> </item> <item><title>By: stacy</title><link>http://www.cyberciti.biz/faq/unix-linux-shell-removing-duplicate-lines/#comment-50410</link> <dc:creator>stacy</dc:creator> <pubDate>Thu, 28 Oct 2010 01:22:13 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=1815#comment-50410</guid> <description>Thanks for the help!! the uniq command took a 1372 line file down to a 32 line file, which was much less daunting!</description> <content:encoded><![CDATA[<p>Thanks for the help!! the uniq command took a 1372 line file down to a 32 line file, which was much less daunting!</p> ]]></content:encoded> </item> <item><title>By: Joseph</title><link>http://www.cyberciti.biz/faq/unix-linux-shell-removing-duplicate-lines/#comment-48576</link> <dc:creator>Joseph</dc:creator> <pubDate>Fri, 30 Jul 2010 20:59:42 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=1815#comment-48576</guid> <description>Thanks for this. Helped me a great deal. For some reason it did leave duplicates but was still hugely helpful and removed a few duplicates manually is much better then making a 1483 line file into a 379 line file like it was supposed to be without duplicates.</description> <content:encoded><![CDATA[<p>Thanks for this. Helped me a great deal. For some reason it did leave duplicates but was still hugely helpful and removed a few duplicates manually is much better then making a 1483 line file into a 379 line file like it was supposed to be without duplicates.</p> ]]></content:encoded> </item> <item><title>By: Vivek</title><link>http://www.cyberciti.biz/faq/unix-linux-shell-removing-duplicate-lines/#comment-48086</link> <dc:creator>Vivek</dc:creator> <pubDate>Sun, 27 Jun 2010 06:36:57 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=1815#comment-48086</guid> <description>How to find the duplicates alone &amp; print in a text file? example i i have in abc.txt
abc dr545.xml
dsf  fg456.xml
abc sfg34.xml
I need a text file with it&#039;s output
abc dr545.xml
abc sfg34.xml</description> <content:encoded><![CDATA[<p>How to find the duplicates alone &amp; print in a text file? example i i have in abc.txt</p><p>abc dr545.xml<br
/> dsf  fg456.xml<br
/> abc sfg34.xml</p><p>I need a text file with it&#8217;s output</p><p>abc dr545.xml<br
/> abc sfg34.xml</p> ]]></content:encoded> </item> <item><title>By: Nathan</title><link>http://www.cyberciti.biz/faq/unix-linux-shell-removing-duplicate-lines/#comment-47694</link> <dc:creator>Nathan</dc:creator> <pubDate>Tue, 08 Jun 2010 16:53:12 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=1815#comment-47694</guid> <description>Thank you so much, this has helped me big time!</description> <content:encoded><![CDATA[<p>Thank you so much, this has helped me big time!</p> ]]></content:encoded> </item> <item><title>By: rh</title><link>http://www.cyberciti.biz/faq/unix-linux-shell-removing-duplicate-lines/#comment-43500</link> <dc:creator>rh</dc:creator> <pubDate>Mon, 31 Aug 2009 14:10:22 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=1815#comment-43500</guid> <description>GOT IT:
# write dup files into text file
sort file1.txt file2.txt &#124; uniq -d &gt; duplicity.txt
# remove duplicated records from both files
for domain in `cat duplicity.txt`; do sed -e &quot;/${domain}/d&quot; -i file1.txt; sed -e &quot;/${domain}/d&quot; -i file2.txt; done</description> <content:encoded><![CDATA[<p>GOT IT:</p><p># write dup files into text file<br
/> sort file1.txt file2.txt | uniq -d &gt; duplicity.txt<br
/> # remove duplicated records from both files<br
/> for domain in `cat duplicity.txt`; do sed -e &#8220;/${domain}/d&#8221; -i file1.txt; sed -e &#8220;/${domain}/d&#8221; -i file2.txt; done</p> ]]></content:encoded> </item> <item><title>By: rh</title><link>http://www.cyberciti.biz/faq/unix-linux-shell-removing-duplicate-lines/#comment-43495</link> <dc:creator>rh</dc:creator> <pubDate>Mon, 31 Aug 2009 10:50:00 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=1815#comment-43495</guid> <description>Does anyone know how should i remove both duplicated lines and put list of all duplicates
into text file
as there will be output
garbage.txt:
food that are killing you
wings of fire
we hope that the labor spent in creating this software
unix ips as well as enjoy our blog
garbage.duplicates.txt:
this is a test
?</description> <content:encoded><![CDATA[<p>Does anyone know how should i remove both duplicated lines and put list of all duplicates<br
/> into text file<br
/> as there will be output</p><p>garbage.txt:<br
/> food that are killing you<br
/> wings of fire<br
/> we hope that the labor spent in creating this software<br
/> unix ips as well as enjoy our blog</p><p>garbage.duplicates.txt:<br
/> this is a test<br
/> ?</p> ]]></content:encoded> </item> <item><title>By: Amber</title><link>http://www.cyberciti.biz/faq/unix-linux-shell-removing-duplicate-lines/#comment-42983</link> <dc:creator>Amber</dc:creator> <pubDate>Mon, 10 Aug 2009 06:33:05 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=1815#comment-42983</guid> <description>that would be uniq followed by filename.</description> <content:encoded><![CDATA[<p>that would be uniq followed by filename.</p> ]]></content:encoded> </item> <item><title>By: Amber</title><link>http://www.cyberciti.biz/faq/unix-linux-shell-removing-duplicate-lines/#comment-42982</link> <dc:creator>Amber</dc:creator> <pubDate>Mon, 10 Aug 2009 06:32:24 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=1815#comment-42982</guid> <description>&lt;i&gt;Martin 09.20.08 at 8:41 am
How can change your example so the output would be (without duplicate lines, but one of duplicates is still there)?
this is a test
food that are killing you
wings of fire
we hope that the labor spent in creating this software
unix ips as well as enjoy our blog
Thank you.
3 Deb 09.20.08 at 10:12 am
uniq -c will do it Martin.
&lt;/i&gt;
uniq -c removes duplicates and leaves one of the lines that have been duplicated. But it also prefixes each line with the number of duplicates that have been removed.
You must use
uniq
without any of the options and your  job is done.</description> <content:encoded><![CDATA[<p><i>Martin 09.20.08 at 8:41 am</p><p> How can change your example so the output would be (without duplicate lines, but one of duplicates is still there)?</p><p> this is a test<br
/> food that are killing you<br
/> wings of fire<br
/> we hope that the labor spent in creating this software<br
/> unix ips as well as enjoy our blog</p><p> Thank you.<br
/> 3 Deb 09.20.08 at 10:12 am</p><p> uniq -c will do it Martin.<br
/> </i></p><p>uniq -c removes duplicates and leaves one of the lines that have been duplicated. But it also prefixes each line with the number of duplicates that have been removed.<br
/> You must use<br
/> uniq<br
/> without any of the options and your  job is done.</p> ]]></content:encoded> </item> <item><title>By: Mikey</title><link>http://www.cyberciti.biz/faq/unix-linux-shell-removing-duplicate-lines/#comment-42441</link> <dc:creator>Mikey</dc:creator> <pubDate>Fri, 10 Jul 2009 00:33:13 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=1815#comment-42441</guid> <description>Read the RUTE. Root users Tutorial and Exposition. This teaches you many of the basics of Linux system administration.</description> <content:encoded><![CDATA[<p>Read the RUTE. Root users Tutorial and Exposition. This teaches you many of the basics of Linux system administration.</p> ]]></content:encoded> </item> <item><title>By: dude</title><link>http://www.cyberciti.biz/faq/unix-linux-shell-removing-duplicate-lines/#comment-41059</link> <dc:creator>dude</dc:creator> <pubDate>Sun, 05 Apr 2009 20:48:44 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=1815#comment-41059</guid> <description>sorry... was going a bit too fast...
sort -u -o garbage.txt garbage.txt
Obviously =)</description> <content:encoded><![CDATA[<p>sorry&#8230; was going a bit too fast&#8230;<br
/> sort -u -o garbage.txt garbage.txt<br
/> Obviously =)</p> ]]></content:encoded> </item> <item><title>By: dude</title><link>http://www.cyberciti.biz/faq/unix-linux-shell-removing-duplicate-lines/#comment-41058</link> <dc:creator>dude</dc:creator> <pubDate>Sun, 05 Apr 2009 20:46:46 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=1815#comment-41058</guid> <description>@lamp:
sort -u -o new_file old_file
e.g. sort -u -o moregarbage.txt garbage.txt</description> <content:encoded><![CDATA[<p>@lamp:<br
/> sort -u -o new_file old_file<br
/> e.g. sort -u -o moregarbage.txt garbage.txt</p> ]]></content:encoded> </item> <item><title>By: LAMP docs</title><link>http://www.cyberciti.biz/faq/unix-linux-shell-removing-duplicate-lines/#comment-39354</link> <dc:creator>LAMP docs</dc:creator> <pubDate>Wed, 03 Dec 2008 05:51:44 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=1815#comment-39354</guid> <description>What will be the command to save the output of this command to the same file? Or maybe a script?</description> <content:encoded><![CDATA[<p>What will be the command to save the output of this command to the same file? Or maybe a script?</p> ]]></content:encoded> </item> <item><title>By: Jadu Saikia</title><link>http://www.cyberciti.biz/faq/unix-linux-shell-removing-duplicate-lines/#comment-38830</link> <dc:creator>Jadu Saikia</dc:creator> <pubDate>Sun, 21 Sep 2008 03:34:54 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=1815#comment-38830</guid> <description>One more approach keeping the order of lines same as input. The good thing about this is that it can be applied if we need to remove duplicate based on a field or fields.
$ awk &#039;!x[$0]++&#039; garbage.txt
Output:
this is a test
food that are killing you
wings of fire
we hope that the labor spent in creating this software
unix ips as well as enjoy our blog</description> <content:encoded><![CDATA[<p>One more approach keeping the order of lines same as input. The good thing about this is that it can be applied if we need to remove duplicate based on a field or fields.</p><p>$ awk &#8216;!x[$0]++&#8217; garbage.txt</p><p>Output:<br
/> this is a test<br
/> food that are killing you<br
/> wings of fire<br
/> we hope that the labor spent in creating this software<br
/> unix ips as well as enjoy our blog</p> ]]></content:encoded> </item> <item><title>By: Deb</title><link>http://www.cyberciti.biz/faq/unix-linux-shell-removing-duplicate-lines/#comment-38821</link> <dc:creator>Deb</dc:creator> <pubDate>Sat, 20 Sep 2008 10:12:50 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=1815#comment-38821</guid> <description>uniq -c will do it Martin.</description> <content:encoded><![CDATA[<p>uniq -c will do it Martin.</p> ]]></content:encoded> </item> </channel> </rss>
