Software >> OS >> Windows >> Command Line >> For >> How to use FOR to process each line in a text file

------------------------------------------------------------ extract space separated words ------------------------------------------------------------ eg. servers.txt contains list of servers, one per line For running from command prompt > FOR /F "tokens=1 delims= " %i in (servers.txt) do echo %i For running from batch file > FOR /F "tokens=1 delims= " %%i in (servers.txt) do echo %%i ------------------------------------------------------------ To extract the entire phrase in a line (incl of spaces) for /F "tokens=1 delims=*" %a in (file.txt) do echo %a for /F "tokens=1 delims=*" %%a in (file.txt) do echo %a