less - macOS


less is a command-line tool for viewing and navigating text files, such as log files, source code, and configuration files. It offers interactive scrolling, search, and navigation capabilities, making it easier to inspect and analyze textual content.


less [-options] [-i|-I] [-k] [-p] [-s] [-S] [+][line] [file ...]
less [--help | --version]


  • -i or -I: Ignore case in search.
  • -k: Enable highlighting of search terms.
  • -p or -P: Set the prompt to a file containing commands.
  • -s or -S: Display line numbers.
  • -T tag: Define a tag to jump to.
  • -x: Display lines in reverse order.
  • +line: Start at the specified line number.
  • -q: Display file without running preprocessor.
  • -R: Disable regex interpretation of search patterns.
  • -w: Display lines not containing the search term.
  • –help: Display help message.
  • –version: Display program version.


  • View the system log: less /var/log/system.log
  • Search for a term in a file: less -k patterns.txt | grep pattern
  • Browse a file starting from line 10: less +10 package.json
  • Ignore case in search: less -i config.ini | /pattern
  • Disable line numbers: less -S commands.sh

Common Issues

  • Text not displayed correctly: Check if the file is encoded properly (e.g., UTF-8) or if the pager setting is configured accordingly.
  • Cannot search: Make sure the search term is correct and case-sensitive (unless using -i).
  • Highlighting not working: Ensure the -k option is specified, and the search term matches the highlighting rules.


less can be used in conjunction with other commands, such as:

  • tail -f log.txt | less: Continuously monitor a log file.
  • find . -exec less ‘{}’ +: View the contents of multiple files sequentially.
  • grep pattern file.txt | less: Filter and display matching lines from a file.
  • more: Similar to less but offers fewer navigation options.
  • head: Displays the first few lines of a file.
  • tail: Displays the last few lines of a file.
  • man: Displays manual pages for macOS commands.