The most easiest way to count the number of lines, words, and characters in text file is to use the Linux command “ wc ” in terminal. The command “ wc ” basically means “word count” and with different optional parameters one can use it to count the number of lines, words, and characters in a text file.
![]() ![]()
If you’ve been using a Mac for any length of time, you know that it’s more than just a pretty point-and-click, window-and-icon interface. Beneath the surface of OS X is an entire world that you can access only from the command line. Terminal (in your /Applications/Utilities folder) is the default gateway to that command line on a Mac. With it, instead of pointing and clicking, you type your commands and your Mac does your bidding.Why would you want to do that? For almost all of your computing needs, the regular graphical user interface is enough. But the command line can be handy when it comes to troubleshooting your Mac, to turn on “hidden” settings, and other advanced chores.
Many of the hints we publish on the website require the use of the command line. It’s a good idea for anyone who isn’t an utter beginner to be familiar with it.If you aren’t already familiar with OS X's command-line interface, this week we'll get you up to speed. The plan is to cover the most important commands you need to know and show you how to use them.
First up: How to navigate the file system from the command-line prompt. The promptBy default, when you open Terminal, the first thing you’ll see is something like this: Last login: Tue Apr 23 13:40:35 on ttys000walden: kirk$The first line shows the last time you logged into your Mac via the command line; that’s the current time, when you’re using Terminal.
The second line is the prompt, and while it can change from system to system depending on configuration, by default it contains several bits of information.In my prompt, walden is the name of my Mac (same as the name in the Sharing pane of System Preferences), and kirk is my user name. The shows where I am in the file system of my Mac; is a shortcut that means the current user’s home folder. (In the Finder, that’s the folder with your user name and the house icon.) Finally, the $ is a character that the bash shell (the default interface that Terminal uses) displays to indicate that it’s ready to accept a command.
What’s in a folderWhen you first get to the command line, you’re in your home folder. While you’re there—or when you’re in any folder ( directory in Unix-speak)—you might want to know what’s in it. To do that you use the ls (or list) command. Type ls and press the Return key, and you’ll see the folders (and/or files) in the current directory.The output of the plain ls command is pretty sparse; it shows you the names of files and folders contained in the current directory (including some familiar ones such as Movies, Music, Pictures, and so on). Fortunately, you can add a number of optional switches to the ls command that allow you to see more information.
![]()
So, for example, try typing ls -l (that’s a lower-case L), then pressing Return.
![]() Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
January 2023
Categories |