LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   command to show updates to files (https://www.linuxquestions.org/questions/linux-newbie-8/command-to-show-updates-to-files-680786/)

gustavolinux 11-03-2008 05:27 AM

command to show updates to files
 
Folks, do anybody knows a command like 'less', but that automatically show updates to the content of the file? I want to see 'real time' the change of the content of some file...

I thought that the parameter '-R' (repaint) of 'less' would do this, but I tested and nothing...

thanx by the attention folks...

[ ]'s

i92guboj 11-03-2008 05:37 AM

It depends on what do you mean.

If what you want is to see how contents is being added to a file (for example, to monitorize a log file), you can use tail. for example, in an xterm you could do:

Code:

tail -f /var/log/messages
There are variants like mtail that can use colors and other features.

gustavolinux 11-03-2008 05:48 AM

that`s perfect

thanx pretty much!

tidww01 11-03-2008 05:54 AM

I'm not sure I understand what you mean. If you are talking about a log file that has data appended onto the end of it, then a tail -f would show the data being appended. Otherwise you would probably have to write a script that slept for a period of time then awoke to check the last modified time of file, I haven't tested the following, but something like,

touch /tmp/compare_time
do while (1)
sleep 30
find /log_dir -name "file_name" -newer /tmp/compare_time
if [ $? -eq 0 ]
then
touch -m /tmp/compare_time
less /log_dir/file_name
fi
done

john test 11-03-2008 10:55 AM

Would not the command "watch" do this job?


All times are GMT -5. The time now is 12:20 PM.