Get "PHP 8 in a Nutshell" (Now with PHP 8.5)
Amit Merchant
Amit Merchant

A blog on PHP, JavaScript, and more

Count number of lines in a file in terminal

To check the number of LINES in a file (robots.txt in the following example), run the following command in your terminal.

wc -l robots.txt

# 15 robots.txt

This will return the number of lines in the file robot.txt along with the filename. Useful probably for checking length of CSVs or similar.

Was that useful? Consider leaving a

Tip

👋 Hi there! This is Amit, again. I write articles about all things web development. If you enjoy my work (the articles, the open-source projects, my general demeanour... anything really), consider leaving a tip & supporting the site. Your support is incredibly appreciated!

Comments?