Skip to content

Instantly share code, notes, and snippets.

@eeddaann
Last active October 3, 2017 18:09
Show Gist options
  • Save eeddaann/6d20779d2d25d6c713705317a5d48f86 to your computer and use it in GitHub Desktop.
Save eeddaann/6d20779d2d25d6c713705317a5d48f86 to your computer and use it in GitHub Desktop.
read stdout from hanging command

dealing with hanging bash process

This line is helpful when you only need a keypress to continue the hangging process: echo dummy_text | COMMAND

When you want to wait for specific pattern from stream and exit: bash -c 'cat <(COMMAND & grep -m 1 PATTERN)'

When you want to wait for 3 seconds and exit: bash -c 'cat <(COMMAND & sleep 3s)'

  • bash -c added because command substitution is not supported on pre-POSIX systems.
  • cat <(..) prints out what written inside
  • COMMAND & run the command in background
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment