there are commands like
iwevent
or
tcpdump -n src host x.x.x.x
that send to the stdout some lines when something happens. Is there any form of running some command inmmediatly after a line is printed. Ex:
iwevent | echo "Wireless event happened"
Just read stdin in a loop
iwevent | while IFS= read -r line; do
echo "[$(date "+%F %T")] - $line"
done
Depending on what you do in the loop body, you might want
while IFS= read -r line; do
echo "[$(date "+%F %T")] - $line"
done < <(iwevent)
That avoids the implicit subshell effects of using a pipeline.
Not sure I get what you mean, but something in the direction of this?
while IFS= read -r line; do
printf "%s\n%s\n" "$line" "Yohooo! One more package."
done < <(tcpdump -i any -nS)