Prepend message to rsstail

2019-08-21 12:29发布

问题:

I am trying to prepend a message to the output of rsstail, this is what I have right now:

rsstail -o -i 15 --initial 0 http://feeds.bbci.co.uk/news/world/europe/rss.xml | awk -v time=$( date +\[%H:%M:%S_%d/%m/%Y\] ) '{print time,$0}' | tee someFile.txt

which should give me the following:

[23:46:49_23/10/2014] Title: someTitle

After the command I have a | while read line do ... end which never gets called because the above command does not output a single thing. What am I doing wrong?

PS: I am using the python version of rsstail, since the other one kept on crashing (https://github.com/gvalkov/rsstail.py)

EDIT:

As requested in the comments the command:

rsstail -o -i 15 --initial 0 http://feeds.bbci.co.uk/news/world/europe/rss.xml

Will give back a message like the following when a new article is found

Title: Sweden calls off search for sub

回答1:

It seems that my rsstail is different from yours, but mine supports the option

-Z x    add heading 'x'

so that

rsstail -Z"$( date +\[%H:%M:%S_%d/%m/%Y\] ) " ...

does the job without awk; on the other hand, you do have some problem with buffering, is it possible to ask rsstail to stop after a given number of titles?



标签: bash awk tee