Say I have a command
my_command that outputs multiple lines.
I would like to capture the first line of
my_command's output as soon as it's ready in a script, while keeping
I thought something like this would work:
# Get a code that `my_command` prints in its first line parsed_first_line=`my_command | grep -oEe '[0-9]+'` echo 'Here is the first line ' $parsed_first_line
but it doesn't. The echo statement is only reached only once
my_command has fully finished, which is not what I want.
Getting into more details: Imagine
my_command is actually a command that connects my shell to a remote shell. Would this change in any way our solution to Part 1?
In case the details matter,
my_command is actually a one-line command:
This is a
Platform LSF command that submits a job from a login machine (an interactive zsh shell in our case) to a remote grid. Once the submited job gets an open slot on the grid, LSF dispatches it, giving me an interactive shell on the remote machine.
The first thing
bsub does is output the
job ID of my job on the remote queue (this is what I hope to parse in my script), and then once a slot is open, it dispatches my job.
I'm wondering if a trivial solution to Part 1 would work for Part 2