Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

After viewing a file in less, with the convenience of scrolling to the side and searching, I want to be able to view/copy the contents of that file normally in my terminal window without having to run cat on it.

Using the -X option, the output of less is not cleared from the screen after exiting, but anything beyond the right boundary of the window is truncated, and a lot of junk for showing the scrolling gets left behind.

Is there a one-liner or option that would leave behind cat-like output after exiting less? The closest I got was with cat foo.txt | tee >(less), which gives me a hard time when trying to quit less.

cat foo.txt | tee /dev/tty | less works even better than that, but when I use it as a pager in MySQL, it tends to cut off short of printing the whole result table.

share|improve this question

1 Answer 1

I'm not sure what the problem with less -X is. It seems to work perfectly well on my system, the lines are folded and everything looks fine. Anyway, how about just using more instead of less? The output stays on screen by default, you can still search in the same way, just use Enter or Space to scroll down and b to scroll backwards.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.