2

When I use putty.exe to SSH a Linux server, I usually use a console width of ~ 160 columns (configurable in the Putty settings, Window tab).

But even with this, when you do things like cat /var/log/apache2/access.log, each line is broken in two lines which makes it difficult to read. Of course cat ... | cut -c 1-160 could help but then the rest of the line is not displayed.

Question: on Windows, how to SSH a Linux server, with a virtual console width of, say, 2000 characters, and a horizontal scrollbar?

TL;DR instead of this:

enter image description here

I'd like this, with a horizontal scrollbar and a very large console width:

enter image description here


Edit: I'd like to be able to scroll horizontally on already-written files, on currently-being-updated files (such as Apache logs), but also in realtime on the ouptut of, for example a Python script like this:

import time
for i in range(10):
    print(str(i)*200)
    time.sleep(1)

How to see the output of this script without line-breaks in the terminal, but still see the output being written in realtime, and not have:

000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000
111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111
...
...

but instead:

0000000000000000000000000000000000000...
1111111111111111111111111111111111111...

with the ability to scroll horizontally?

In this case doing python script.py |less -S does not work: it is not displayed second after second in realtime. Doing python script.py |less -S +F does not work either because the horizontal scrolling -S cannot be used at the same time of the "tail -f mode".

2 Answers 2

2

Use less -S to read the files.

1
  • Thank you @user1686 for this answer, it is very useful for logs! How would you do to apply this method also to the output of a Python script? I've added an Edit at the end of my question to explain what I mean. Thanks in advance if you have an idea!
    – Basj
    Jul 18, 2021 at 19:23
1

Addition to the accepted answer, for future readers/future reference:

  • If you want to visualize a constantly-updated log the way described in the question, you can either do:

    less +F -S access.log
    

    It will then be in "tail -f mode", showing Waiting for data...(interrupt to abort)". To quit this mode, you can do CTRL+C.

  • Another way is to do:

    less +G -S access.log
    

    which automatically positions the cursor at the end of the end, but does not auto-update the display in real-time (in the case new data is appended). In the case you want to enter this "tail -f mode", doing SHIFT+F is helpful.


Important note: while in auto-updating "tail -f mode", you cannot scroll horizontally with the arrow keys, you have to quit this mode with CTRL+C, then move horizontally, and then redo SHIFT+F to re-enter in "tail -f mode".

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .