Use “tail -f” to monitor and report, but the top line should be always fixed on the screen. | Unix Linux Forums | Shell Programming and Scripting

  Go Back    

Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Use “tail -f” to monitor and report, but the top line should be always fixed on the screen.

Shell Programming and Scripting

tail -f monitor head

Closed Thread    
Thread Tools Search this Thread Display Modes
Old 01-30-2013
df3c df3c is offline
Registered User
Join Date: Jan 2013
Last Activity: 28 February 2013, 11:44 AM EST
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Oracle Use “tail -f” to monitor and report, but the top line should be always fixed on the screen.

Title: Use “tail -f” to monitor and report, but the top line should be always fixed on the screen.
Hi, dear Unix experts,

I am trying to find a Unix command (or scripting) on how to continuously display a text file of its last several lines of contents. But during this displaying, I want some of the top lines are always displayed on the screen top when the scrolling contents reach the screen top.

To make a simple, a text file “test001.log” is in its running process with the ending lines adding.
tab1	tab2	tab3	tab4	tab5
0.9	5.0	17.7	9.7	19.9
0.6	9.1	4.3	0.6	41.9
0.0	2.8	14.9	5.0	5.6
0.2	5.8	62.4	17.3	41.5
0.6	8.0	74.9	0.7	19.4
0.7	4.3	48.1	2.8	30.3
0.0	5.3	0.3	16.4	42.8
0.2	7.8	70.8	11.6	10.8
0.6	7.5	89.4	19.7	34.9
0.4	2.5	88.5	0.1	22.7
0.4	1.1	41.3	8.4	18.6

Say, I want to use some commands like “tail –f”, but it will show a total number of 10 lines. The top line (possibly several lines in the middle) always shows “tab1 tab2 tab3 tab4 tab5”. The rest 9 lines show the last latest updated 9 lines. Such scrolling should not exceed outside my Unix screen shell.

I’ve tried to search such function in many websites, but haven’t found useful information. I would think this function is very useful. But can I do it?

Thanks in advance.

Moderator's Comments:
Please use code tags next time for your code and data.
Sponsored Links
Old 01-30-2013
gary_w's Avatar
gary_w gary_w is offline
Registered User
Join Date: Oct 2010
Last Activity: 10 December 2014, 5:14 PM EST
Posts: 446
Thanks: 32
Thanked 96 Times in 88 Posts


while :
  printf "tab1\ttab2\ttab3\ttab4"
  tail -9 test001.log
  sleep 5

Sponsored Links
Old 01-30-2013
RudiC RudiC is offline Forum Advisor  
Registered User
Join Date: Jul 2012
Last Activity: 1 February 2015, 12:34 PM EST
Location: Aachen, Germany
Posts: 5,165
Thanks: 89
Thanked 1,325 Times in 1,245 Posts
man console_codes:
ECMA-48 CSI sequences

CSI (or ESC [) is followed by a sequence of parameters, . . .
r DECSTBM Set scrolling region; parameters are top and bottom row.
e.g. echo -en "\033[2;45r" followed by an ^L (ctrl L, clear screen) will clear the screen, put your first line (=header) into row 1, and then scroll happily the text coming below that, i.e. between lines 2 and 45.
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How do I get my script to monitor a new file using tail? lstorm2003 Shell Programming and Scripting 4 06-06-2009 09:58 AM
tail command not show on screen seyha_moth Shell Programming and Scripting 10 12-27-2008 10:26 AM
How to print string on screen according the fixed length? a2156z Shell Programming and Scripting 1 10-24-2008 06:29 AM
Bash tail monitor log file kriezo Shell Programming and Scripting 2 03-28-2006 12:01 AM
Looking for monitor/top pavelmac UNIX for Dummies Questions & Answers 1 09-28-2005 12:12 AM

All times are GMT -4. The time now is 02:09 PM.