read

cmd/read

Read and inspect file content

Overview

read reads and inspects text files.

Main modes:

  • Plain read: read <file>
  • Head/tail: read top, read last
  • Search: read pattern
  • Counters: read count

Example usage:

read /var/log/system.log
read top /var/log/system.log --lines=20
read last /var/log/system.log --lines=50 --follow
read pattern error /var/log/system.log --ignorecase --numbers
read count /var/log/system.log

Usage

  • read <file> [--numbers]
  • read top <file> [--lines=N]
  • read last <file> [--lines=N] [--follow]
  • read pattern <pattern> <file> [--ignorecase] [--numbers] [--count]
  • read count <file>

Subcommands

NameDescription
top Show first N lines
last Show last N lines
pattern Search for pattern
count Count lines/words/chars

Flags

FlagTypeDescription
-numbers - Show line numbers

Exit Codes

CodeMeaning
0 Success
1 Runtime/command error
2 Invalid flags/usage