solo2500
Posts: 123
Joined: Sat Jul 09, 2016 12:38 am

Continually display contents of text file on desktop?

Mon Nov 05, 2018 2:52 pm

I have a text file that gets updated every few minutes. Is there a way to continuously view the contents without having to close and open the file all the time? I suppose one could write a small scrip and have it run continuosly... but it seems like there should be a more elegant way?
I'm a total novice, non-programer (...basically a hack.)

ElEscalador
Posts: 839
Joined: Tue Dec 15, 2015 4:55 pm
Location: Detroit, MI USA
Contact: Website

Re: Continually display contents of text file on desktop?

Mon Nov 05, 2018 3:06 pm

I guess I have to ask what does the updating of said file? If that's a local program I'd probably use that program to output whatever it is to make it easier to avoid trying to read and write at the same time. That said I'm kind of a caveman and would write a c++ (python probably easier but I don't speak python) That would open and output the file contents to an ugly but simple console window.
Robotics tips, hacks, book extras https://youtube.com/practicalrobotics

DirkS
Posts: 10363
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: Continually display contents of text file on desktop?

Mon Nov 05, 2018 4:11 pm

solo2500 wrote:
Mon Nov 05, 2018 2:52 pm
I have a text file that gets updated every few minutes. Is there a way to continuously view the contents without having to close and open the file all the time? I suppose one could write a small scrip and have it run continuosly... but it seems like there should be a more elegant way?
both

Code: Select all

less +F filename
tail -f filename
will do that
Last edited by DirkS on Mon Nov 05, 2018 4:47 pm, edited 1 time in total.

solo2500
Posts: 123
Joined: Sat Jul 09, 2016 12:38 am

Re: Continually display contents of text file on desktop?

Mon Nov 05, 2018 4:34 pm

DirkS wrote:
Mon Nov 05, 2018 4:11 pm
solo2500 wrote:
Mon Nov 05, 2018 2:52 pm
I have a text file that gets updated every few minutes. Is there a way to continuously view the contents without having to close and open the file all the time? I suppose one could write a small scrip and have it run continuosly... but it seems like there should be a more elegant way?
both

Code: Select all

less +S filename
tail -f filename
will do that
Thanks for the reply but neither one of these seem to "update" whenever the file gets changed?
I'm a total novice, non-programer (...basically a hack.)

DirkS
Posts: 10363
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: Continually display contents of text file on desktop?

Mon Nov 05, 2018 4:47 pm

solo2500 wrote:
Mon Nov 05, 2018 4:34 pm
Thanks for the reply but neither one of these seem to "update" whenever the file gets changed?
Ah... typo alert. It's 'less +F'

solo2500
Posts: 123
Joined: Sat Jul 09, 2016 12:38 am

Re: Continually display contents of text file on desktop?

Mon Nov 05, 2018 5:03 pm

I'm a total novice, non-programer (...basically a hack.)

User avatar
scruss
Posts: 3218
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: Continually display contents of text file on desktop?

Mon Nov 05, 2018 5:26 pm

solo2500 wrote:
Mon Nov 05, 2018 4:34 pm
Thanks for the reply but neither one of these seem to "update" whenever the file gets changed?
How is your file changing? tail -f assumes you are appending data to a log file, so will only show the changed lines at the end. If the whole file changes, you might not see the changes correctly.

I don't know of any off-the-shelf program that does this automatically. There are things you might be able to do with the watch and inotify commands … and I see you found one!
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.
Pronouns: he/him

User avatar
rpdom
Posts: 17174
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Continually display contents of text file on desktop?

Mon Nov 05, 2018 7:06 pm

scruss wrote:
Mon Nov 05, 2018 5:26 pm
solo2500 wrote:
Mon Nov 05, 2018 4:34 pm
Thanks for the reply but neither one of these seem to "update" whenever the file gets changed?
How is your file changing? tail -f assumes you are appending data to a log file, so will only show the changed lines at the end. If the whole file changes, you might not see the changes correctly.
tail --follow works like tail -f, but realises if the file changes completely and tracks those changes too.

User avatar
scruss
Posts: 3218
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: Continually display contents of text file on desktop?

Tue Nov 06, 2018 2:40 am

tail --follow and tail -f are exact synonyms: check the manual and info page.
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.
Pronouns: he/him

User avatar
rpdom
Posts: 17174
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Continually display contents of text file on desktop?

Tue Nov 06, 2018 5:57 am

scruss wrote:
Tue Nov 06, 2018 2:40 am
tail --follow and tail -f are exact synonyms: check the manual and info page.
Hmm, odd. I've had differing results with the two options.

Return to “Beginners”