DOS command equivalent for "uniq"

G

Guest

Hi,

Is there an equivalent DOS command for UNIX "uniq" command? Or maybe several
DOS commands have to be used together to achieve the same?
 
H

Herb Martin

Michelle said:
Hi,

Is there an equivalent DOS command for UNIX "uniq" command? Or maybe
several
DOS commands have to be used together to achieve the same?

Not built-in but UnxUtils which offer many Unix-like tools for
Win32 is worth having.
http://unxutils.sourceforge.net/

However they have messed up their download page and you have to
hunt for someone else (reliable) offering them:

Google: [ unxutils GNU win32 ]
 
T

Timo Salmi

Michelle said:
Is there an equivalent DOS command for UNIX "uniq" command? Or maybe
several DOS commands have to be used together to achieve the same?

97) I need to remove duplicate entries from the output or a file.
193214 Feb 16 2007 ftp://garbo.uwasa.fi/pc/link/tscmd.zip
tscmd.zip Useful NT/2000/XP script tricks and tips, T.Salmi

All the best, Timo
 
H

Harlan Grove

Michelle said:
Is there an equivalent DOS command for UNIX "uniq" command? Or maybe
several DOS commands have to be used together to achieve the same?

FTHOI, you could always roll your own using WSH/VBScript. Put the
following into a file named uniq.vbs.

'-- begin uniq.vbs ----
Dim tr, pr

pr = -1

With WScript
Do
tr = WScript.StdIn.ReadLine
If tr <> pr Then WScript.StdOut.WriteLine tr
pr = tr
Loop Until WScript.StdIn.AtEndOfStream
End With
'-- end uniq.vbs ----

Then use it in a command line like

cscript //nologo uniq.vbs < yourinputfile > youroutputfile
 
Joined
Oct 8, 2012
Messages
1
Reaction score
0
the following bat script (say uniq.bat) does the job:

set previousLine=
for /f "tokens=* delims= " %%l in (%*) do (
if not %%l == !previousLine! (
echo %%l
)
set previousLine=%%l
)

then: uniq[.bat] file.txt. for it to work the command window must be started with delayed variable interpretation, i.e. cmd.exe /v:blush:n.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top