Wednesday, January 19, 2011

DOS BATCH - (FIND)

EXAMPLE:

@echo off
echo .. >> "USERS_DISC_%COMPUTER%.txt"
echo %DATE% %TIME% >> "USERS_DISC_%COMPUTER%.txt"

for /f "tokens=1,3" %%a in (qwinsta^|find /i "disc"') do CALL :process %%a %%b %%c
call USERS_DISC_%COMPUTER%.txt
goto:eof

:process
echo [%2] %1 >> "USERS_DISC_%COMPUTER%.txt"
goto:eof


Searches for a text string in a file or files.

FIND [/V] [/C] [/N] [/I] [/OFF[LINE]] "string" [[drive:][path]filename[ ...]]

/V Displays all lines NOT containing the specified string.
/C Displays only the count of lines containing the string.
/N Displays line numbers with the displayed lines.
/I Ignores the case of characters when searching for the string.
/OFF[LINE] Do not skip files with offline attribute set.
"string" Specifies the text string to find.
[drive:][path]filename
Specifies a file or files to search.

If a path is not specified, FIND searches the text typed at the prompt
or piped from another command.

No comments:

Post a Comment