UNIX Cadillac Commands (MacBook)

Besides working with files and processes, the command line has all kinds of sophisticated commands. For example, with the command line, you have instant access to a variety of tools for finding files or even stringing together commands.

Finding files

The command line gives you a number of ways to search for files on your hard drive. The two most commonly used commands are find and locate.
To use find, specify a starting point for the search followed by the name of the file or folder that you want to find. For example, to find the Fonts folder that belongs to your user, enter the command like this:
find ~/ -name “Fonts”
You should see at least one result of the find command. /Users///Library/Fonts
One great feature of the find command is that you can look for a file or folder in more than one location. Suppose you want to find a file named MyDocument that you know resides either in your Documents folder or on your Desktop. For this kind of search, use the find command like this:
find -/Documents -/Desktop -name “MyDocument”
In this example, you are telling the find command which folders it should search when looking for the file named MyDocument.

Using pipes

Nearly all UNIX commands can take on greater abilities by using a construct called the pipe. A pipe (I) is represented by that funny little vertical line that shows up when you press Shift+\. The pipe routes data from one command to another one that follows — for example, many UNIX commands produce large amounts of information that can’t all fit on one page. (You might have noticed this behavior if you’ve used the locate command.) Joining two commands or functions together with the pipe command is piping. To tame the screens full of text, pipe the find function to the less command. The less command provides data one page at a time.
find ~/ -name “Fonts” | less
When the results fill up one page, the data stops and waits for you to press any key (except the Q key) to continue. When you reach the end of the results, press Q to quit and return to a command-line prompt.

Next post:

Previous post: