Re: findstr, for, or other command to do this?
From: wadester (null_at_devnull.net)
Date: 04/27/04
- Next message: wadester: "Re: Xcopy behavior questions"
- Previous message: David Candy: "Re: Xcopy behavior questions"
- In reply to: djc: "findstr, for, or other command to do this?"
- Next in thread: djc: "Re: findstr, for, or other command to do this?"
- Reply: djc: "Re: findstr, for, or other command to do this?"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 27 Apr 2004 15:21:29 -0500
In article <uoLcquILEHA.1312@TK2MSFTNGP12.phx.gbl>, noone@nowhere.com
wrote...
> Situation: I have a log file with many fields and lines. Each line has say
> a computername field. The same computername will be listed several times
> thoughout the file. What if I wanted a list of computer names from the file?
> meaning 1 instance of each name returned from a command?
>
> example: A log file has 2 fields. ComputerName and DLLVersion. I want to
> construct a command or batch file that will return a unique list of computer
> names that do not have a DLLVersion equal to 4.1.002. Just using the find
> command gets me close but its not a unique list. The same computer names
> will be listed multiple times.
>
> any input is appreciated. Thanks.
Here's a starting place, at least:
Input file in.txt:
computer1 1.0
computer2 2.0
computer1 1.0
computer2 2.0
computer1 3.0
computer2 3.0
Find all unique computer names not at v3.0:
==========================================
@echo off
setlocal enabledelayedexpansion
del tmp.$$$ >nul 2>&1
for /f "tokens=1" %%I in ('findstr /v "3.0" in.txt ^| sort') do (
echo %%I >> tmp.$$$
)
REM Parse thru the sorted temp file and compare each
REM line to the previous one
set oldline=.
for /f %%l in (tmp.$$$) do (
set line=%%l
if !line! NEQ !oldline! echo !line!
set oldline=!line!
)
==========================================
ws
-- I saw this in a movie about a bus that had to SPEED around a city, keeping its SPEED over fifty, and if its SPEED dropped, it would explode. I think it was called, "The Bus That Couldn't Slow Down."
- Next message: wadester: "Re: Xcopy behavior questions"
- Previous message: David Candy: "Re: Xcopy behavior questions"
- In reply to: djc: "findstr, for, or other command to do this?"
- Next in thread: djc: "Re: findstr, for, or other command to do this?"
- Reply: djc: "Re: findstr, for, or other command to do this?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|