How can I keep long strings from truncating in terminal? For example if I run
There's a lot of text that I cannot read. I am open to using other programs/tools.
Stack Exchange network consists of 181 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.Visit Stack Exchange
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
The output is paged through less by default, and long lines are "truncated" to screen width. The hidden part can be viewed by using the left-arrow and right-arrow keys. Paging can be disabled; see the --no-pager option and the "Environment" section below.
If you don't want to constantly be using the left and right arrow keys, simply pipe it directly to
$ journalctl -xn | less
This will wrap lines that are too long for your terminal (the default behavior of
Or, of course, if you don't mind possibly having to use your terminal's scrollback, you could use no pager at all:
$ journalctl -xn --no-pager
LESSdoes not include
-S, journalctl should not be applying
-Sto the invocation of
less!! That is, setting PAGER=less and LESS=$x (where $x is any string that does not contain S) should give the desired behavior. Nov 11, 2018 at 13:19
SYSTEMD_PAGER="less -r" journalctl -xn
I also do:
journalctl -xn | less
But you can also set the
SYSTEMD_LESS environment variable:
SYSTEMD_LESS=FRXMK journalctl -xn # Or even # SYSTEMD_LESS="" journalctl -xn # The environment variable needs to be there, but can be the empty string
I got that from: [systemd-devel] [PATCH] pager: wrap long lines by default
Set it in your .bashrc and be done with it! :-)
systemd needs to setup
less specially and doesn't just honor the less defaults and the
LESS environment seems a little arrogant to me, but hey, this works...
Defaults env_keep += "LESS SYSTEMD_LESS"to
/etc/sudoers. It's for those times when I accidentally put
sudoin front of e.g.
systemctl status. Sep 14, 2018 at 17:51
If the program already uses
less (if not, pipe the output to it), you can enable/disable line wrapping by typing
less), This works for other
less options as well.
Note also that:
will show you all the latest as it comes in and wrap like any normal human being (or even sysadmin) would expect to allow easy reading, copy-pasting, and everything else.
$ SYSTEMD_PAGER="less +-S" journalctl
+ executes command on start and
-S disable chopping.
You can also set this value for a session or save in rc/profile script.
This is the command I use for CentOS 7, which preserves coloring and wraps lines:
SYSTEMD_PAGER="less -r" journalctl
I type in terminal,
journalctl | more, works great for me then I use arrows up or down.
-ndefault to 10 lines in log only.