cmd - Windows command line to parse information from a text file -
i have text file contains, amongst other information, lines start 'password: ' . looking run command line command (if possible) parse through .txt file extract of terms follow 'password: ' , place them new textfile listing solely passwords. number of spaces between word 'password:' , actual password varies in entries.
i have far used:
findstr /l "password: " input_file.txt > output_file.txt
this works extracts term 'password: ' too. research have carried out, don't believe command line has built-in function remove strings .txt files thinking run above command followed similar to:-
findstr /l "password: " input_file.txt > output_file.txt & delstr "password: " output_file.txt > final_file.txt & del output_file.txt
obviously have invented 'delstr' said, need there remove string 'password: ' each line.
any suggestions? thanks
in fact, there (very limited) built-in functions string manipulation. see set /?
details.
no need work temporary files, can parse string directly variable:
(code edited print passwords, if there more one)
setlocal enabledelayedexpansion /f "delims=" %%a in ('findstr /b /c:"password: " input_file.txt') ( set pwd=%%a set "pwd=!pwd:password: =!" echo !pwd!>>final_file.txt )
Comments
Post a Comment