Using head and tail Commands in Linux CLI
📖 Scenario: You are working with a text file that contains a list of daily sales records for a small shop. You want to quickly check the first few and last few lines of this file to understand the data without opening the entire file.
🎯 Goal: Learn how to use the head and tail commands to view the beginning and end of a text file in the Linux command line.
📋 What You'll Learn
Create a text file named
sales.txt with specific linesUse
head command to view the first 3 linesUse
tail command to view the last 2 linesPrint the outputs of both commands
💡 Why This Matters
🌍 Real World
Checking the start and end of log files or data files quickly without opening the entire file saves time and helps find important information fast.
💼 Career
System administrators, developers, and data analysts often use head and tail commands to inspect files and troubleshoot issues efficiently.
Progress0 / 4 steps