How to disable line wrap in a terminal?

Try:

less -S +F filename

=

less --chop-long-lines +F filename

And then:

  • Press Ctrlc to stop tailing and now you can move left and right using cursor keys.
  • Press Shiftf to resume tailing
  • Press Ctrlc, q to quit

less manual: + If a command line option begins with +, the remainder of that option is taken to be an initial command to less.

For example, +F tells less to scroll forward, and keep trying to read when the end of file is reached


Found a good answer from superuser, that works out of the box for gnome-terminal, and probably for other terminals as well:

setterm -linewrap off

enter image description here


Supposing you have the COLUMNS variable defined, you can execute

tail -f your-app.log | cut -c -$COLUMNS

otherwise substitute $COLUMNS with the columns width of the terminal, as obtained by stty -a.

Tags:

Terminal