Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to stop displaying long long file list of `ls`?

Tags:

linux

ls

putty

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

It starts to display a very long file list, and seems never end.

How to stop it, without closing the putty program?

like image 204
Freewind Avatar asked Sep 09 '13 07:09

Freewind


People also ask

What is the command to display the long format listing of files?

List files in long format. Type the ls -l command to list the contents of the directory in a table format with columns including: content permissions.

What ls option displays a long listing format type in the -)?

The -l option signifies the long list format. This shows a lot more information presented to the user than the standard command. You will see the file permissions, the number of links, owner name, owner group, file size, time of last modification, and the file or directory name.

When displaying a long listing of files D stands for directory what does the L prefix indicate about the type of file?

The leading l indicates that this file is a symlink, in contrast to - which indicates a regular file, d which indicates a directory, and other less common prefixes. A symlink is type of file which only contains a link to another file. Reading a symlink reads the real file.

What is the correct command to display the list of last 5 files present in the current directory?

Now, tail command gives last 5 lines of the data and the output goes to the file name list.


3 Answers

You can control the ls output by using less or more command, like below:

ls | more
ls | less

They'll work on interactive way. Or you can truncate output with head or tail command, like:

ls | head
ls | tail

head will show default 10 lines from head and tail will show default 10 lines from tail.

like image 155
rakib_ Avatar answered Nov 03 '22 07:11

rakib_


If you are over SSH, you can use escape sequences. For example to send break, press:

enter, ~ and B

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

Other interesting ones

Terminate time-outing 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.)
like image 26
julumme Avatar answered Nov 03 '22 06:11

julumme


You can stop the output by pressing Ctrl + C (like it's the case with most programs inside the linux shell).

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

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

like image 1
Marco Hegenberg Avatar answered Nov 03 '22 06:11

Marco Hegenberg