Forums before death by AOL, social media and spammers... "We can't have nice things"
|    alt.msdos.batch    |    Fun with MS-DOS batch files    |    42,547 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 41,504 of 42,547    |
|    Konrad to All    |
|    Re: How do I read a pipe inside a batch     |
|    19 Oct 16 16:04:22    |
   
   From: spam2074@arcor.de   
      
   Hi,   
      
   I think you always need a separate program to read multiple lines from   
   stdin in a for /f loop.   
   As mentioned before you can use more.exe or eg. findstr.exe /r /c:.* for   
   that.   
   When you want to include empty lines for filtering too you could use   
   sed.exe. Here is an example batch code (call it MyFilter.bat):   
      
      
   @echo off   
   SetLocal EnableDelayedExpansion   
      
   REM sed.exe inserts one '#' char at the start of each line in order to   
   include empty lines too   
   for /f "delims=" %%d in ('sed -e "s/.*/#&/g"') do (   
    set "_LINE_=%%d"   
    REM remove the prviously inserted first '#' char   
    set "_LINE_=!_LINE_:~1!"   
      
    REM ... insert your own filtering code here ...   
      
    echo.!_LINE_!   
   )   
      
      
   So you can use it like:   
      
   dir | MyFilter.bat   
      
      
   Regards Konrad   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca