Where to start First steps track · 15 stages
Linux Labs

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.txt the first 10 lines
  • head -n 3 file.txt the first 3 lines
  • head -n -5 file.txt everything except the last 5 lines
  • head -c 100 file.txt the first 100 bytes
  • head -n 1 data.csv a table's header line
  • head -n 2 a.txt b.txt 2 lines of each, with names
  • ps aux --sort=-%mem | head the top of a long output

Options

-n 3 and the short form -3 are the same. Full list — man head.

Loading…