QA Graphic

WC command

Easily count the number of words in a PDF document using WC

The WC command is a simple command to display the "word count" of anything passed to it. You can even pass in PDF documents to see how many OCR words are in the file.

Look at a PDF document

wc /Users/root/Desktop/HotelHistory.pdf
340 1408 31827 /Users/root/Desktop/HotelHistory.pdf
[340 lines 1,404 words 31,827 characters]

Find the number of Errors in a Log

This will count the number of times an error appears by a certain date. You can loop this in a BASH script to see how many times it appears on some days.

cat /mnt/xd/server/debug.log | grep 27/Apr/2019 | grep "Exception" | wc -l

General Reference

wc -w gives only the word count.
wc -l gives only the line count.
wc -c gives only the byte count.
wc -m gives only the character count.

Why This Post?

As part of the A-Z April challenge, today's letter is 'W.' Oddly enough, there are not that many interesting things on the Macintosh that start with W.

One Option I had was to review Watermark Pro, but I thought it was more interesting to learn more about the 'wc' Unix command. I also wanted to share some of my knowledge.

 

About

A Mac veteran since 1989, I'm here to share my experience with tips and tricks every Friday. Witnessing the evolution of Mac software and hardware firsthand, I've gained a deep understanding of how these machines work and can help you troubleshoot any issues that may come up.

Schedule

WednesdayAffinity
ThursdayBBEdit
FridayMacintosh
SaturdayInternet Tools
SundayOpen Topic
MondayMedia Monday
TuesdayQA