Usage of uniq command option | Unix Linux Forums | UNIX for Dummies Questions & Answers

  Go Back    


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

Usage of uniq command option

UNIX for Dummies Questions & Answers


Tags
uniq, uniq commnd problem

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 04-12-2010
texasvader34 texasvader34 is offline
Registered User
 
Join Date: Apr 2010
Last Activity: 13 April 2010, 3:51 PM EDT
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Usage of uniq command option

How to use the -D option of 'uniq' command in unix ??

It has additional parameters that can be passed as given in the manual...but i am not sure how to use it...

for example,

-D, --all-repeated[=method] Print all duplicate lines. -D takes no delimiter method. The delimiter method method takes one of the following values: none (default), prepend, or separate. Blank lines are used as the delimiter.
how do i pass the value 'separate' to the command ???


i tried

uniq -D [separate] doc.txt


and many such combinations...i dont know to send the parameter 'separate' to the command..



Plz Help
Sponsored Links
    #2  
Old 04-12-2010
Scrutinizer's Avatar
Scrutinizer Scrutinizer is offline Forum Staff  
Moderator
 
Join Date: Nov 2008
Last Activity: 24 July 2014, 4:06 AM EDT
Location: Amsterdam
Posts: 9,281
Thanks: 260
Thanked 2,303 Times in 2,066 Posts
According to the man page -D takes no delimiter method
Try:

Code:
uniq --all-repeated=separate

Sponsored Links
    #3  
Old 04-13-2010
texasvader34 texasvader34 is offline
Registered User
 
Join Date: Apr 2010
Last Activity: 13 April 2010, 3:51 PM EDT
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks Scrutinizer ! it worked ...

I have one more question..i was going thru the source code for uniq.c ..

There I can see that we can give input to the uniq program from stdin ...

I dont know how we can do that...i mean we can specify the infile containing the text ... how do we specify the text as it is in the command ??

Thanks,
    #4  
Old 04-13-2010
denn denn is offline
Registered User
 
Join Date: Jul 2007
Last Activity: 10 December 2010, 1:31 PM EST
Posts: 116
Thanks: 0
Thanked 2 Times in 2 Posts
one of many ways.


Code:
cat FILENAME | sort | uniq

Sponsored Links
    #5  
Old 04-13-2010
Corona688 Corona688 is offline Forum Staff  
Mead Rotor
 
Join Date: Aug 2005
Last Activity: 24 July 2014, 2:03 PM EDT
Location: Saskatchewan
Posts: 18,976
Thanks: 748
Thanked 3,145 Times in 2,951 Posts
First off, you get a useless use of cat award. Also, if you're using sort, you don't need uniq. You can thus do everything in your snippet in one process instead of three:
Code:
sort -u < FILENAME

Sponsored Links
    #6  
Old 04-14-2010
Scrutinizer's Avatar
Scrutinizer Scrutinizer is offline Forum Staff  
Moderator
 
Join Date: Nov 2008
Last Activity: 24 July 2014, 4:06 AM EDT
Location: Amsterdam
Posts: 9,281
Thanks: 260
Thanked 2,303 Times in 2,066 Posts
I think in this case though what Denn was trying to demonstrate is one of the ways of making uniq read from stdin as the poster requested, so for that purpose it is useful use of cat.
Sponsored Links
    #7  
Old 04-14-2010
denn denn is offline
Registered User
 
Join Date: Jul 2007
Last Activity: 10 December 2010, 1:31 PM EST
Posts: 116
Thanks: 0
Thanked 2 Times in 2 Posts
exactly, and you can also get two awards:
one for not reading the subject matter;
then being inaccurate on your example.

uniq only works to remove duplicates if used on a sorted list.
Quote:
NAME
uniq - report or omit repeated lines

SYNOPSIS
uniq [OPTION]... [INPUT [OUTPUT]]

DESCRIPTION
Discard all but one of successive identical lines from INPUT (or standard input), writ-
ing to OUTPUT (or standard output).
i.e. if duplicate lines are not successive, uniq will do nothing.
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Uniq command behaving odd phoenix_nebula UNIX for Dummies Questions & Answers 3 02-18-2010 11:58 PM
correct usage of find's -prune option ProGrammar Solaris 6 04-29-2009 12:22 PM
Help with uniq command Bandit390 Shell Programming and Scripting 2 02-27-2009 06:39 PM
uniq command??? skyineyes UNIX for Dummies Questions & Answers 2 05-28-2008 06:27 AM
Usage of prstat -j option. vipin771 UNIX for Dummies Questions & Answers 1 11-14-2007 09:10 PM



All times are GMT -4. The time now is 03:18 PM.