Bash wrap lines?

Posted on 2006-04-26
Last Modified: 2010-05-18
I'm trying to read the last couple of lines of a log file using a bash shell. tail -f /file works fine but for one small problem. The lines in the file are too long to display on the screen so it truncates them. I need to see the end/truncated part of the line. Is there a way to make tail do this or another program I can pipe the tail output into in order to see the entire line wrapped on screen?

Question by:albee01
    LVL 1

    Expert Comment

    I think tail only does that when the output is a tty... try piping the result through cat.
    LVL 1

    Author Comment

    Nope. No such luck. cat does the same thing. I'm connected via ssh if that helps.
    LVL 4

    Accepted Solution

    Neither tail nor cat truncate lines, so something *else* is causing your problem.

    My first guess is that it's your terminal program.  You mention SSH (which also *should* not be truncating), but don't mention how.

    What OS are you running locally -- Linux (or other *UX) , Windows, Mac?
    What terminal program are you using?  Putty, Gnome-terminal, xterm, etc...

    Try checking the settings for the program you're using and see if you don't have line truncation set, or scroll bars suppressed.

    Also, on the remote machine try this:    stty -a
    which should display a number for "columns" that should correspond to what you are using locally.

    If it doesn't show a number that corresponds to your system, you *could* try this, which might or might not help:
        stty columns 80  

    Good luck
    LVL 1

    Author Comment

    NVRAM pointed me in the right direction so they get the points. It turns out to be a setting in Putty under the terminal section ("Auto wrap lines initially on") which was not selected.
    LVL 4

    Expert Comment

    Glad to help.  BTW, I'm a "he" not that it matters. ;-)

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Course: HTML5 Mobile App Development with PhoneGap

    PhoneGap can help you leverage your already existing HTML5, JavaScript, and CSS skills in order to create and deploy cross-platform mobile apps.This program comprehensively covers HTML5 mobile app development from top to bottom.

    Suggested Solutions

    This is an explanation of a simple data model to help parse a JSON feed
    Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
    An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
    In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now