FG
💻 Software

Bash command to cut output after x number of lines

Fresh5 days ago
Mar 15, 202656336 views
Confidence Score0%
0%

Problem

I'm looking for a bash command, which I can use to limit the number of lines of a file or another command output. E.g. would limit the output of the ls command to 10 lines (in the example, the command "limit" is naturally a imaginary command, whose equivalent I'm looking for). Is there such command…

Error Output

ls -thor | limit 10

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: Bash command to cut output after x number of lines

Low Risk

Use head: 10 lines is the default. Read the head man page for more options. (older versions of head also support usage without the explicit as in )

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment