Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Every once in a while on a computer I'm ssh'd into, I will accidentally type "cat largefile.txt" and my screen will start rushing with text for the next 10 minutes. I'm always working in a screen session, so my current solution is to just log out and then log back in, and since it can go 100X faster when I'm logged out, it'll finish in the short time it takes me to type my password in again.

Is there a better way? Either involving the fact I'm in a screen session? Or a way to do this within SSH?

What doesn't work:

  • detaching from the screen session (doesn't respond until file is done outputting)
  • trying command to move to a different window in the screen session (also doesn't respond)
  • typing ctrl+C to kill cat command (also doesn't respond, probably because the command is done and the buffers just have to catch up)
share|improve this question

3 Answers 3

up vote 7 down vote accepted

The obviously easy solution would be to not use cat. Your shell isn't a text viewer. Use less which is designed for this.

share|improve this answer
    
Well, my system doesn't have less, but it does have more, which I use all the time when I realize I'm dealing with a large file "cat file.txt|more"... guess I should just train myself to use "more file.txt" in all situations though. No real reason to use cat when the terminal is the output. –  Jarvin May 7 '10 at 19:36

If you're using Bash, try Ctrl-z kill % Enter

What shell are you using?

(Ctrl-c works for me, by the way.)

share|improve this answer
    
I'm using bash. Ctrl+C works if you can get it off before cat finishing processing, but by the time I realize it is super long, cat is no longer running, and it is just my display that has to catch up. So it is not that I have to kill anything, because cat is already no longer running. Ctrl-Z doesn't do anything while the file is outputting. –  Jarvin May 7 '10 at 19:21

If you start a new screen window via ^A ^C, you will I think be able to "dodge" the oncoming buffer without having to logout & log back in again. It seems that the bottleneck is transmission of the buffer characters to your local terminal; switching to another window should alleviate the need for this effort. Not exactly a miracle cure, but it could save you some time.

share|improve this answer
    
Sadly, this doesn't work. Just like all the other methods this only helps if the cat hasn't finished executing. Once it finishes and the only thing left is for the buffer to catch up, the only way I've found is just to log out. The cat usually finishes in under a second or two, so I type this almost instantly in order for it to have any effect. –  Jarvin Jul 6 '10 at 14:51
    
That's interesting. Have you tried backgrounding the SSH connection? This seems unlikely to work, since it seems like you need the screen session to be detached... but then presumably you would have tried just detaching from the screen session with ^A d. How are you logging out? Anyway hitting [ENTER]``~``^Z will background the SSH session. –  intuited Jul 6 '10 at 15:10

Your Answer

 
discard

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.