If I understand you correctly, then probably you want to do:
sh -c '{ fsusage #your command runs (indefintely?)
kill -PIPE "$$" #but when it completes, so does this shell
} >&3 & #backgrounded and all stdout writes to pipe
while sleep 5 #meanwhile, every 5 seconds a loop prints
do echo #a blank line w/ echo
done' 3>&1 | #also to a pipe, read by an unbuffered (GNU) sed
sed -u '
### if first input line, insert shell init to stdout
### for seds [aic] commands continue newlines w/ \escapes
### and otherwise \escape only all other backslashes
1i\
convenience_func(){ : this is a function \\\
declared in target \\\
shell and can be \\\
called from sed.; }
### if line matches object change it to command
/object/c\
# this is an actual command sent to a shell for each match
### this is just a comment - note the \escaped newlines above
### delete all other nonblank lines; change all blanks
/./d;c\
# this is a command sent to a shell every ~5 seconds
' | sh -s -- This is the target shell and these are its \
positional parameters. These can be referred \
to in sed\'s output like '"$1"' or '"$@"' as \
an array. They can even be passed along to \
'convenience_func()' as arguments.
About 90% of the above consists of comments. Basically it can be boiled down to...
sh -c '(fsusage;kill "$$") >&3 &
while sleep 5; do echo; done
' 3>&1|
sed -nue '/pattern/c\' -e 'echo match
/./!c\' -e 'touch -- "$1"
' | sh -s -- filename
fs_usage
ever terminate? If not you need a different approach. Whattail
does is get you the last line(s). It can't know what the last line is until its input terminates, so as long as the pipe chain is held open tail will never output anything. – jw013 Dec 3 '14 at 19:50fs_usage
does not terminate. Could you suggest another approach then? – Christoph90 Dec 3 '14 at 19:53fs_usage
yields new output. – Christoph90 Dec 3 '14 at 20:07