LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   linux text editor which updates file (https://www.linuxquestions.org/questions/linux-newbie-8/linux-text-editor-which-updates-file-914949/)

sparsh0mittal 11-22-2011 01:36 PM

linux text editor which updates file
 
I run simulations where output is printed in file. Is there a linux text editor which automatically updates files (while they are open and I am viewing them), in case it is not changed without asking (this will be something like console output). I will be thankful for the help.

Thanks
Sparsh

corp769 11-22-2011 01:55 PM

You could use the tail command with the -f argument to watch text files live. Do you have the text editor open to edit the file while it is being updated, or do you just want to watch it live?

Edit - As an example:
Code:

tail -f /var/log/messages

sparsh0mittal 11-22-2011 02:35 PM

Thanks. But tail command only shows the last lines.

My scenario is: while a simulation is going on, it prints same output in both std::cout and also a log file. After sometime, the std::cout stops printing any output, so I have to rely on the log file.

Now to understand the simulation, I need to understand the output while simulation is going on (they are long simulations). So if I use vim to open log file, it does not update the file (every time I have to close and open). So I was looking a gui/non-gui based editor, which could keep on updating my view of the log file.

Thanks.

corp769 11-22-2011 02:48 PM

Oh, ok... With vim, you can set the following:
Code:

:set autoread
From the man page/help files:
Quote:

When a file has been detected to have been changed outside of Vim and it has not been changed inside of Vim, automatically read it again. When the file has been deleted this is not done.

sparsh0mittal 11-22-2011 03:05 PM

Quote:

Originally Posted by corp769 (Post 4530938)
Oh, ok... With vim, you can set the following:
Code:

:set autoread

Thanks a lot. That does the task.

corp769 11-22-2011 03:08 PM

Awesome! There a most likely other alternatives besides vim and tail, but if that works for you, then it works. Could you also mark your thread as solved, using the thread tools located at the top of the page? Thanks!

Cheers,

Josh

MTK358 11-22-2011 04:54 PM

Code:

tail -n +1 -f
That will print the entire file.

corp769 11-22-2011 04:59 PM

Quote:

Originally Posted by MTK358 (Post 4531052)
Code:

tail -n +1 -f
That will print the entire file.

Forgot about that. That works, but if the file is really big, then technically it is kind of pointless, if you really think about it, especially when you are using a regular terminal, instead of an emulator like gnome-terminal, etc.


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