Another option: use a redirect to subshell. This changes the order in which background processes are started, so $! gives PID of the tail
process.
tail -f $1 > >(nc -l -p 9977) &
wait $!
More Related Contents:
- How can I pipe stderr, and not stdout?
- Pipe output and capture exit status in Bash
- How to trick an application into thinking its stdout is a terminal, not a pipe
- What is a simple explanation for how pipes work in Bash?
- How to pipe input to a Bash while loop and preserve variables after loop ends
- How can I detect if my shell script is running through a pipe?
- Bash variable scope
- How to check if a process id (PID) exists
- Why piping input to “read” only works when fed into “while read …” construct? [duplicate]
- Capture both stdout and stderr in Bash [duplicate]
- Piping and Redirection
- How to pipe multiple commands into a single command in the shell? (sh, bash, …)
- Pipe, standard input and command line arguments in Bash
- How to pipe stdout while keeping it on screen ? (and not to a output file)
- pipe stdout and stderr to two different processes in shell script?
- Pipe output to two different commands [duplicate]
- Get exit code from subshell through the pipes
- bash piping prevents global variable assignment
- How to detect if a Node.js script is running through a shell pipe?
- What’s the difference between “here string” and echo + pipe
- Left side of pipe is the subshell?
- How do I kill a backgrounded/detached ssh session?
- Convert absolute path into relative path given a current directory using Bash
- Convert date time string to epoch in Bash
- How do I put an already-running process under nohup?
- How to find whether or not a variable is empty in Bash
- Loop only iterates once with `ssh` in the body [duplicate]
- Send command to a background process
- Subtract two variables in Bash
- Multidimensional associative arrays in Bash