head Command Builder — Linux head Examples
Linux head Command Builder (Preview First Lines)
The head command is used to preview the first lines or bytes of a file in Linux. This interactive head Command Builder helps you generate precise head commands for quick file inspection.
🚀 What is the head Command?
The head command allows you to:
- Preview the first lines of any text file
- Preview the first bytes of a file
- Inspect CSV headers and log file starts
- Quickly check file contents without opening an editor
⚙️ Basic Syntax
head [options] FILE
head [options] FILE1 FILE2 ...🧠 How to Use This head Command Builder
This tool helps you:
- Choose how many lines or bytes to preview
- Switch between line mode (
-n) and byte mode (-c) - Control filename headers for single or multiple files
- Generate a ready-to-use head command
Workflow
- Select the file(s) to preview
- Choose line count with
-nor byte count with-c - Toggle headers with
-q/-vfor multi-file output - Copy generated command
🔧 Common head Usage Patterns
Preview First 20 Lines of a Log
head -n 20 app.logPreview a CSV Header Row
head -n 1 data.csvPreview the First 100 Bytes
head -c 100 notes.txtWindow Into the Middle of a File (Offset Trick)
tail -n +100 app.log | head -n 20Show All But the Last 50 Lines
head -n -50 app.logControl Headers for Multiple Files
head -v file1.log file2.log
head -q file1.log file2.log⚠️ Important Notes
- Default is 10 lines: bare
head fileprints only the first 10 lines - Lines vs bytes:
-ncounts lines,-ccounts bytes - Headers:
-valways shows filenames,-qnever shows them - NUL-delimited: use
-zfor zero-terminated lines (e.g.find -print0output)
✅ Pro Tips
- Use
head -n 1to grab a CSV header before piping to other tools - Combine with
tailto window any line range without an editor - Use
-cto sanity-check binary file signatures safely - Add
-vwhen comparing the tops of several files at once