Find the answer to your Linux question:
Results 1 to 3 of 3
Greetings, From a shell script I would like to display the output of tail -f. While doing this, I want to restrict the output to the last 15lines of my ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    May 2010
    Posts
    2

    screen - tail box


    Greetings,

    From a shell script I would like to display the output of tail -f. While doing this, I want to restrict the output to the last 15lines of my screen only (and allow it to overwrite itself).

    I thought of using curses to define my own window - however initscr() call wipes out the entire screen first.

    The 'screen' utility looks promising, I can split the screen using Ctr+a S. However how do I do this programmatically while invoking screen itself?

    I would like to invoke my main shell script as well as this 'tail box' (if I can call it that, without offending 'dialog' users)....

    Any help is greatly appreciated!

  2. #2
    Linux Newbie theNbomr's Avatar
    Join Date
    May 2007
    Location
    BC Canada
    Posts
    155
    How about something like
    Code:
    xterm -geometry 80x15 -e 'tail -f /var/log/yourfile'
    --- rod.
    Stuff happens. Then stays happened.

  3. #3
    Linux Enthusiast
    Join Date
    Jan 2005
    Location
    Saint Paul, MN
    Posts
    663
    Quote Originally Posted by theNbomr View Post
    How about something like
    Code:
    xterm -geometry 80x15 -e 'tail -f /var/log/yourfile'
    --- rod.
    The quotes on the command should not be there. The remainder of the command line after the "-e" is the command and the quotes turns the whole command into a single field. Also this solution does not restrict the output only to 15 lines as the scroll buffer is not set to 15 lines. The correct solution would be:
    Code:
    xterm -geometry 80x15 -sl 15 -e tail -f /var/log/messages &
    The "-sl 15" sets the scroll buffer to 15 lines. For those not understanding the "-geometry 80x15" defines a window having 15 rows of 80 characters per row. Before KDE and Gnome, text based applications used the width and height in characters rather than in screen real estate sizes which was very nice and xterm is one of the oldest X applications.

    Other geometry options include placement information:
    -geometry widthXheight+xoffset+yoffest
    Note that the "+" can be a "-" for from bottom or right edges rather than from the top and left edges.

    Also note that KDE and Gnome still have this options (which is slightly modified do that all applications use screen real estate width and heights and the format is changed.
    --geometry widthxheigh+x+y
    or
    --geometry=widthxhight+x+y

    Also note in all cases the +x+y can be used without the widthxheight portion.

  4. $spacer_open
    $spacer_close

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •