Unix command to get top 10 from the sorted file names in current directory [closed]

StackOverflow https://stackoverflow.com/questions/22667946

  •  21-06-2023
  •  | 
  •  

سؤال

I understand that the command to list alphabetically the file names in current directory is ls.

But how can I get top 10 from the sorted file names in current directory?

هل كانت مفيدة؟

المحلول

Use the command "head" to get the first ten lines:

ls | head -10

نصائح أخرى

With sorting:

ls | sort | head -10

A note that ls doesn't sort naturally. So a file that starts with T will show before a file beginning with a.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top