0

I am using a bash command that outputs a large quantity of data and all I need is to see the command that was run and the output that fits on the screen afterward. Is there a keyboard shortcut for this? I would prefer to not use head or change the command at all

Clarifying Way After the Fact

I have a bunch of different combinations of commands being run and their output displayed right after, I just want to be able to jump up to the previously run command or have commands output only a screens worth of output, but I have to copy the command after so I don't want to use head for that reason.

2

IF your terminal (- emulator) understands DEC VT10x console codes, you could set the scrolling region to the last two rows of the screen after clearing it:

echo -e "\e[2J\e[$((LINES-1));${LINES}r"

Your command and its output's first screen will be seen afterwards. Typing reset will undo the changes.

0

I think tput li shows the number of lines of your terminal window. Subtract two and then use that value with a head -n to show only the first n lines of output. That will leave your command on the first line and the prompt on the last line.

0

A solution for bash involving shortcuts:

  1. Start your program with big output
  2. Once the screen is filled, hit CTRL + s to suspend output
  3. To resume output, hit CTRL + q

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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