Get "PHP 8 in a Nuthshell" (Now with PHP 8.4)
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! I'm Amit. I write articles about all things web development. You can become a sponsor on my blog to help me continue my writing journey and get your brand in front of thousands of eyes.

Comments?