Andy G
Andy G

Reputation: 418

Stopping FOR /F command at first line of output (Windows batch)

So, I need to pull the last promote message from our Accurev stream and put it in a Jenkins variable to include in Jenkins email. The only problem I'm having is with multiple line promote messages. I really only want the first line of the promote message, but that's not what I'm seeing with my FOR /F command:

FOR /F "tokens=1-25 delims=;" %i in ('accurev.exe hist -s <stream> -t now.1 ^|FIND "#"') DO @echo %i

with multiple line promote message, I get this output:

 # This is a multiple line promote message
 # because my programmers need to include
 # accurate descriptions of the CRs that # they work on.

So, any way to have my for command stop after collecting the first line?

Upvotes: 1

Views: 2066

Answers (2)

Giuliano Rodrigues
Giuliano Rodrigues

Reputation: 9

FOR /F "tokens=1-25 delims=;" %i in ('accurev.exe hist -s <stream> -t now.1 ^|FIND "#"') DO @echo %i && goto:eof

Upvotes: -1

Endoro
Endoro

Reputation: 37569

try this with GNU grep for Windows:

FOR /F "delims=;" %i in ('accurev.exe hist -s <stream> -t now.1 ^|grep -m1 "#"') DO @echo %i

Upvotes: 2

Related Questions