LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-26-2015, 06:54 AM   #1
iwtbf
Member
 
Registered: Apr 2009
Location: cybernetic space
Distribution: debian
Posts: 42

Rep: Reputation: 1
Edit and direct continuously output from program (rsstail)


I'm using rsstail and I want to edit the output.

rss gives continuously output on the form

Code:
$ » rsstail -l -n 4 -u https://news.ycombinator.com/rss
Title: Why does Windows not recognize my USB device if I plug it into a different port?
Link: http://blogs.msdn.com/b/oldnewthing/archive/2004/11/10/255047.aspx
Title: LLVM merges SafeStack
Link: https://github.com/llvm-mirror/llvm/commit/7ffec838a2b72e6841d9fb993b5fe6a45f3b2a90
Title: Life paint
Link: http://www.volvolifepaint.com/
Title: Uber's Original Blog and First Posts
Link: http://uberexpansion.com/flashback-original-uber-blog/
My goal is to get a text file consisting of only the links
http://blogs.msdn.com/b/oldnewthing/...10/255047.aspx
https://github.com/llvm-mirror/llvm/...5fe6a45f3b2a90
http://www.volvolifepaint.com/
... etc, for later use.

That is, for every output something like
Code:
echo -e "Title: The man with 1,000 Klein Bottles UNDER his house - Numberphile\nLink: http://www.youtube.com/watch?v=-k3mVnRlQLU" | awk NR\>1 | cut -c7-
But since the output of rsstail is continuous and I think the ">>"-operator is char-by-char I'm not sure how to accomplish this.

I guess an alternative would be to just
Code:
rsstail -l -n 4 -u https://news.ycombinator.com/rss >> output.txt
and then edit the output.txt file with a cronjob or something but it would be nicer to do it on the fly.

Any suggestions or pointers on how to do this?
Any help would be highly appreciated!
 
Old 06-27-2015, 05:16 PM   #2
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,780

Rep: Reputation: 2213Reputation: 2213Reputation: 2213Reputation: 2213Reputation: 2213Reputation: 2213Reputation: 2213Reputation: 2213Reputation: 2213Reputation: 2213Reputation: 2213
Just piping the output through sed should do the job.
Code:
rsstail -l -n 4 -u https://news.ycombinator.com/rss | sed -n 's/^Link: //p'
Translation: Do not print anything by default (-n). On all lines that begin with "Link: ", delete those characters and print what remains.

But, there is still a question of how rapidly you want to see the output. When rsstail sees that its stdout is not a terminal, it will likely switch from line-buffered to block-buffered output and wait until it has a full 4K block to write. sed will do the same thing. Some programs have an option to force line-buffering or non-buffering (e.g., the "--line-buffered" option in grep, or the "-u" (--unbuffered) option in sed). If you need the output to appear immediately, you might check whether rsstail has an option like that. Lacking that, there are programs like unbuffer that will present a pseudo-tty device that you can use as the target of the pipe.

If your output is going to a file, you probably don't need to worry about any of that, but if you are testing with output going to a terminal, you need to be aware of the buffering involved.

(unbuffer is typically distributed as part of the expect package.)

Last edited by rknichols; 06-27-2015 at 05:19 PM.
 
Old 06-27-2015, 06:56 PM   #3
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
i've used rsstail for a while and i think it's not very efficient; especially if you have some needs beyond just spitting out plain text.
you might want to hack yourself a script with xmllint or try some html-xml-utils.
once you get the hang of it, it's much easier than fighting with a limited utility.
 
Old 06-29-2015, 05:56 AM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,360

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
You could use this maybe http://search.cpan.org/~mgrabnar/File-Tail-1.2/Tail.pm
 
  


Reply

Tags
bash, rss



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Script for continuously checking if program running, need help tine Programming 4 11-04-2009 01:53 AM
C program to perform an operation continuously until user presses a key ananth86coolguy Linux - Newbie 4 03-13-2009 09:59 AM
Script or program for continuously retrying to get an IP via DHCP Ken-ji Slackware 4 06-18-2008 12:30 AM
How to direct screen output to a variable? vimal Programming 6 08-29-2006 12:06 AM
How to direct output from make to a file? DDD25 Programming 6 07-25-2004 05:55 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:34 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration