How would I print the nth line of a file or input, and block until it exists? I want to stick to coreutils.
sed 'NUMq;d' file will quickly give me the nth line, but doesn't block.
tail -f file will block, but doesn't do the other thing.
I should be able to pipe the line to something else eg with a file:
<block-until-line-20-exists> file | <process-line>
or, with input:
tail -n 0 -f file | <block-until-line-20-exists> | <process-line>
tail -n 0 -f file | block-until-line-20-exists, think about{ while (( i=0; i<20; i++)); do IFS= read -r line; done; printf '%s\n' "$line"; }as something that could fill inblock-until-line-20-exists. Assuming your shell is actually bash; for /bin/sh the loop will be uglier.