How to stop displaying a long long list of `ls` files?

There is a large directory containing 100k files on the remote server, and I typed the command: ls in my putty.

It starts to display a very long list of files and seems to never end.

How to stop it without closing the putty program?

+6
source share
5 answers

If you have finished SSH , you can use escape sequences. For example, to send a break, press:

enter , ~ and B

"enter", of course, is not typed, just press the enter key (I assume that "reset" the current command buffer)

Other interesting

Log out timeout session

enter , ~ and .

Send escape character

enter , ~ and ~

You can list these commands with

enter , ~ and ?

On my system, the above prints:

 # ~? Supported escape sequences: ~. - terminate connection (and any multiplexed sessions) ~B - send a BREAK to the remote system ~C - open a command line ~R - Request rekey (SSH protocol 2 only) ~^Z - suspend ssh ~# - list forwarded connections ~& - background ssh (when waiting for connections to terminate) ~? - this message ~~ - send the escape character by typing it twice (Note that escapes are only recognized immediately after newline.) 
+2
source

You can control the output of ls with the less or more command, as shown below:

 ls | more ls | less 

They will work in an interactive way. Or you can trim the output using the head or tail command, for example:

 ls | head ls | tail 

head will show the default 10 lines from the head and tail, showing the default 10 lines from the tail.

+2
source

You can stop the output by pressing Ctrl + C (as is the case with most programs inside the linux shell).

Edit: just read that Ctrl + C is not working. I think just opening a new console using Alt + F2 doesn't work with Putty either. Then just close the putty window and open a new one. In doing so, you can kill the process.

To read the result, I would suggest using ls | less or print the output to a file and then read it (ls> filelist.txt).

0
source

Putty has a menu where you can access special commands like break

0
source

Try switching to UTF-8 if you are using something else, edit /etc/locale.gen, comment out everything except the line containing UTF-8 for your location, and then run locale-gen to update your system.

-1
source

Source: https://habr.com/ru/post/953457/


All Articles