↑ ↓ select, Enter open, Esc close

Count and sort lines across many files

Adjust the values, the command updates live
user@server
find /var/www/vhosts/example.com/httpdocs/wp-content/themes -type f -name '*.php' -exec wc -l {} + | sort -rn | head -n 20

Finds all files with the given extension, counts their lines with wc -l and sorts in descending order. At the top is the sum as a total line (or insgesamt with a German locale), followed by the longest files. Useful for estimating the size of a theme or plugin, or for spotting unusually large individual files.

Note: With very many files, find calls wc several times, so several subtotals appear.

Also searched as

  • count lines of code in project
  • find longest files linux
  • count lines in all php files

Related one-liners

All in Text processing

Read first, then run.

The commands on myline.de act directly on servers, files and databases. A wrong path or placeholder can delete data irreversibly or make a server unreachable.

  • All commands are provided without warranty and are not tested on every system.
  • Understand what a command does before running it, and check every placeholder.
  • Make a backup first and, if possible, try it on a test system.
  • You run commands at your own risk. Liability for damages is excluded to the extent permitted by law.