Path Search For Mac In Program

Several Unix dialects use the whereis commandto find where programs, or executables, are stored in the filestructure of the computer. To use it at the Unix prompt, enter:

The shell path for a user in macOS or OSX is a set of locations in the filing system whereby the user has permissions to use certain applications, commands and programs without the need to specify the full path to that command or program in the Terminal.This will work in macOS Mojave, Sierra and all older OSX operating systems; El Capitan, Yosemite, Mavericks and Lion.

Replace command with the name of the executable for whichyou are looking. For example, if you are looking for the location ofthe lpr command, you would enter:

The whereis command will return something like thefollowing:

In this example, the query asked about the lpr command,which spools jobs to printers. The operating system returned twoanswers, and thus two paths. The first path is the location of thelpr executable, and the second path is the location ofthe lprmanual page.

To find the path the operatingsystem uses to execute a command when you enter it on the command line, usethe which command instead, for example:

This command will output something like the following:

Program

This means that when you enter lpr at the command line,the system is really executing /var/bsd/lpr.

At Indiana University, for personal or departmental Linux or Unix systems support, see Get help for Linux or Unix at IU.

Sometimes you may wish to get the full path of an item in the Finder, and while there are several ways to access file paths, not all will allow you to extract them as text to paste into documents you may be composing.

For example, if you select a file in the Finder and press Command-C to copy it, the behavior when pasting it will be different, depending on the program being used. In some cases the program will only paste the file name, but in others it may try to embed the file's contents or its icon where you have pasted. The same goes for dragging and dropping files from the Finder; they similarly may be handled either as file names or as icon or content objects.

If you would like to instead just get the file path of the selected document, you can use the Finder's 'Show Path Bar' option in the View menu, open the document in a program and use the path menu, or by searching for the item in Spotlight followed by holding the Option and Command keys while hovering your mouse over a search result to reveal its path in the preview window. However, these approaches do not give you the option to copy the file path as text.

To copy the file path of a file or folder as a text string that you can paste into another document, there are several approaches you can take:

  1. Info windows
    The first option is to use the information window for the item, which will show you the full path to it up to its parent folder. Select the item and press Command-I to open the information window for it, and then locate the path in the General section next to the keyword 'Where.'

    While generally intended to be a quick view of file information, the text content in the information window can be selected by clicking and dragging or by double- and triple-clicking, so you can use these approaches to select the file path and copy it from this window.

  2. Terminal
    The OS X Terminal is one program that can handle file paths via drag-and-drop as text, instead of trying to manage their contents. Being a text-based tool itself, Terminal will quickly output the specified file path as text, which can be selected and copied.

    To do this, simply launch Terminal and then drag a file to its window, and Terminal will output its file path at the command prompt, which you can then copy. You do not need to know any Terminal commands to do this, and can close the Terminal window when you are done copying.

  3. The Go to Folder feature
    The Finder has its Go to Folder feature, which can be used for accessing hidden directories, but similar to the Terminal, you can drag a file or folder here to reveal its full path.

    To do this, open a new Finder window by pressing Command-N, and then press Shift-Command-G to reveal the Go to Folder panel for the new window. Then drag a target file from another window to the Go to Folder text field, where it will be converted to a full text path that you can select and copy. Unfortunately you cannot drag a file from the same window once the Go to Folder panel is open, but you can drag from the desktop or another Finder window.

  4. Create a path-copying service
    If you regularly need to copy a file path as text, an easier option would be to create a service in Automator that will do this for you. First launch Automator and create a new service workflow. Then make sure the inputs for it are 'Files or Folders' in the Finder (done with the menus at the top of the workflow). Then drag the 'Copy to Clipboard' action to the workflow area and save the service with a name like 'Copy Path as Text.'

    While it seems like a replacement for pressing Command-C in the Finder, this approach will ensure that the file paths are copied in full as text instead of only as references that will either be truncated to file names, or be otherwise altered.

    With this service created, you can now select any number of items in the Finder, right-click them, and then choose 'Copy Path as Text' from the Services contextual menu and be able to paste the path (or paths) in the location of your choice. You can also use the keyboard system preferences to assign a custom hot key such as Option-Command-C to the service, so you can invoke it directly.

    Keep in mind that this approach will not copy a file reference, so you cannot use it to move or copy files from one location to another in the Finder, but it will help when managing lengthy and sometimes complex file paths, or the paths of more than one selected item.

Mac system path

Search For Programs On Computer

Questions? Comments? Have a fix? Post them below or e-mail us!
Be sure to check us out on Twitter and the CNET Mac forums.

Path Search For Mac In Programs

  • Review
    Mac OS X 10.8 Mountain Lion