FG
💻 Software

How do I limit the number of displayed lines through ls?

Fresh7 days ago
Mar 15, 202633776 views
Confidence Score0%
0%

Problem

Let's say I have a command How do I limit the output to show me only first 2 files? (except for having only 2 files in that directory)

Error Output

ls -Bgclt /somwhere/in/the/past

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: How do I limit the number of displayed lines through ls?

Low Risk

Simple - you pipe the output through head: You use -n 3 instead of -n 2 because of the 'total' line at the top of the ls output.

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment