DOS command equivalent for "uniq"

  • Thread starter Thread starter Guest
  • Start date Start date
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?
 
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 ]
 
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
 
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
 
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:on.
 
Back
Top