Intern Track Roadmap

Reading files: cat, less, tail

This course covers how the terminal reads files and which command fits each job. It starts with file descriptors, stdin, stdout and stderr, then moves through cat for small files, less for paging and searching, tail for the end of a file and live logs, and head and wc for quick checks. Pipes connect these commands into filters. The last lesson applies the tools to a Rails project, reading the Gemfile, routes, database config and development log to trace a 500 error.

What you'll learn

  • ✓How programs open, read and close files through file descriptors
  • ✓Printing, numbering, joining and inspecting files with cat
  • ✓Paging, searching and jumping to lines with less
  • ✓Reading the end of a file and following logs with tail -f
  • ✓Quick checks with head and wc, and connecting commands with pipes and grep
  • ✓Reading Rails files and logs to trace an error
Free preview · Lesson 1 6 min read

What is reading a file?

Picture a filing cabinet in an office. To read a document inside it, you do three things: you open the drawer, you read the paper, and you close the drawer. Every program on your computer does the same three steps when it reads a file: open, read, close. This sequence is so fundamental that every…

Read the full lesson free →

Curriculum

7 lessons
Type to start searching...