Sample Header Ad - 728x90

How do I limit the number of files printed by ls?

194 votes
6 answers
371132 views
Is there a way to limit the quantity of listed files on a ls command? I've seen: ls | head -4 but to get head or tail to be executed I need to wait for ls to finish execution, and with directories with an enourmous quantity of files that can take considerable time. I wish to execute a ls command that limits without using that head command.
Asked by AndreDurao (2151 rep)
Sep 26, 2011, 07:44 PM
Last activity: Sep 7, 2024, 03:26 PM