0

I have a long running build process that I want to terminate after a certain log output is given.

What i normally do is just watch the process running and when the log entry appears I control-c. Is there a better way to do this, im a Windows guy so dont know where to start.

The command I am running is npx nx run myapp:ios and the log line is Project successfully prepared (ios)

As per Josh Friedlander's comment I have tried the following command and variations but cannot get it to work, the process continues beyond the log line defined:

npm run mybuildscript | while read -r LOGLINE; do echo ${LOGLINE}; [[ "${LOGLINE}" == "Project successfully prepared (ios)" ]] && pkill -P $$ npm; done
Matt
  • 11
  • 3
  • Something like [this](https://superuser.com/a/449307/616774) might work for you (not zsh-specific). Idea is to pipe your process to `while` `read`, which will look for the line and then kill the process by name (not id) – Josh Friedlander Mar 31 '22 at 09:20
  • Rather than explicitly kill a process based on its log output, I would look at how to use the build tool to only do what you want in the first place. – chepner Mar 31 '22 at 16:23

0 Answers0