less and wc
Reading and counting.
Sometimes you want to read a long file properly, page by page, and search inside it. And sometimes you just want to know how big it is. Less, and WC, do those jobs.

- Read page by page
- Or count what's inside
- less and wc
Reading with less
Less opens a file in a viewer, one screen at a time. Space goes down a page, B goes back up. The arrow keys move one line. Slash, followed by a word, searches for it, and N jumps to the next match. And Q quits. It's the same viewer that man uses for manual pages.
Counting with wc
WC stands for word count. It prints three numbers. Lines, words, and characters, followed by the name. Our notes have three lines, six words, and thirty characters. Dash L counts just the lines, which is the one you'll use most.
wc notes.txt 3 6 30 notes.txt wc -l logs/server.log 60 logs/server.log
Counting files
Here's a neat trick. LS Pictures shows two photos. Now LS, then a vertical bar, then WC dash L, counts the items in the folder. The bar is called a pipe. It sends the output of one command into another. Pipes are so useful, they get their own lessons later.
ls Pictures beach.jpg party.jpg ls Pictures | wc -l 2
Summary
Less reads long files page by page, Q quits, and WC counts lines, words, and characters. Next, writing text into files from the terminal.
Key takeaways- less <file>
- q to quit
- wc -l counts lines