As described in the title, I want to know the process id of tail
and nc
.
It is easy to use $!
to get the pid of nc
, but how about tail
?
From comments - you're wanting to terminate these processes once a separate event occurs.
Try a subshell. ( cat -v
in the below for my testing)
eg
( tail -f /path_to_file/ | cat -v ) & echo $!
This will give you a pid of a spawned subshell, which you can kill and get your sub processes at the same time.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.