Using Basic Unix Commands

Most Unix commands observe a specific way of typing commands, known as a command syntax. Unix's command syntax typically involves typing a command (frequently a program name) followed by parameters that specify how that command should perform. These parameters are important because many Unix commands, unlike the GUI programs you use in OS X, do not seek further user input after they have been launched. After typing a command, you must always press Return (often referred to as Enter in Unix help documents and labeled as such on PC keyboards) to issue the command, much as you would click OK to confirm your selections in a dialog box.

For example, to view files via the command line, type ls and press Return. (From this point I assume you know to press Return at the end of each command.) After doing so, you see a list of the files in the current folder.

However, if you want to see only Word documents, add a parameter to narrow the list results. For example, *.doc narrows the list to any filename (the * wildcard special character is explained earlier in this chapter) ending in .doc (the file extension for Word files): ls *.doc.

If you also want to display the results in a detailed list with information such as permissions and date, rather than multiple columns, you can add another parameter: ls –l *.doc. The –l is the parameter that says to show a detailed list.

Many commands can have dozens or even hundreds of different parameters and parameter combinations. ...

Get OS X Mountain Lion Bible now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.