head — the first lines of a file
cheat sheet · Ubuntu 24.04 · GNU coreutils 9.4 https://lab.dimsanych.ru/en/wiki/head/Cheat sheet
-
head file.txtthe first 10 lines -
head -n 3 file.txtthe first 3 lines -
head -n -5 file.txteverything except the last 5 lines -
head -c 100 file.txtthe first 100 bytes -
head -n 1 data.csva table's header line -
head -n 2 a.txt b.txt2 lines of each, with names -
ps aux --sort=-%mem | headthe top of a long output
Options
-n 3 and the short form -3 are the same. Full list — man head.