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?
 
Ad

Advertisements

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
 
Ad

Advertisements

H

Herb Martin

Rich Pasco said:
Look at http://www.richpasco.org/utilities/unique.html

It's not a DOS command but a Windows 32-bit console application, which
may be what you really wanted.
Nice small collection of utlities you offer there thanks.

Most of us were just being sloppy calling these "DOS" apps -- it's incorrect
but makes pretty good short hand for "console applications".
 
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
 
Ad

Advertisements

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

Similar Threads

DOS commands 7
DOS Command 3
dos commands 3
runas dos command 6
command line equivalent of search... 4
Dos if command to do a check . 7
doesn't recognize some dos command 4
Pass 2 variables into dos FOR command 4

Top