# gnome-find User Manual

Most options are self-explanatory, or correspond with the man page for GNU find. For gnome-find, this user manual will highlight some of the differences and/or additions not found in GNU find.

- Printing search results
- Executing a command on files found
- Finding files which contain a specific string of text
- Commands which require user input (from the keyboard)
- Manually specifying a search

### Printing search results

1. Non-GUI versions of GNU "find" can normally print its search results to two places: to stdout (to the console screen), or to a file. For stdout, this is done using one of these options: `-print`, `-print0`, `-ls`, or `-printf`. Similarly, for printing to a file, these are available: `-fprint`, `-fprint0`, `-fls`, `-fprintf`. Please refer to the GNU "find" man page for details about each of these options.
2. gnome-find adds two additional options for printing output to a graphical window. `-wprint` simply prints the resulting pathname found from the search, while `-wls` prints file details. These two options basically deliver the same output as `-print` and `-ls`.
3. Hence, for certain features and text entries where options need to be specified, one will typically need to use `-wprint` and `-wls` to get the desired output into the graphical output window.

### Executing a command on files found

1. There are two options which allow you to execute a customly specified command on files found from a search, `-exec` and `-ok`. However, in gnome-find, there are a number of subtle differences/caveats.
2. First, the text specified must not escape the trailing semicolor. For example, the following command using the normal GNU "find" will delete all files found starting in the current directory:

   `find . -exec rm {} \;`

   Notice that the semi-colon must be escaped (in this case, with a backslash) because the shell normally treats the semi-colon as a special character. Thus for both the `-exec` and `-ok` options in gnome-find, one simply needs to enter the following in the text entry field:

   `rm {} ;`

3. As with GNU "find", `{}` specifies the filename which was found from the search. Also as with GNU "find", `{}` may only occur once for each use of `-exec` or `-ok`. For example, if you wanted to rename each file by appending a ".BAK" extension to the filename, the following command will not work:

   `mv {} {}.BAK ;`

   The proper way to do something such as this is to specify a shell script to execute which will do the renaming.

### Finding files which contain a specific string of text

1. Normally in GNU "find", there is no option which allows you to do this. It would be useful if there was a `-grep` option, so that you could something like this:

   `find . -grep "Look for this text" -print`

2. Unfortunately, there is no such option. The proper way to do something like this is to use the `-exec` or `-ok` action to execute the `grep` command:

   `find . -exec grep -l "Look for this text" {} \;`

3. In gnome-find, an easy interface for this is provided. Under the `Special` sub-section for `Actions` in the `Advanced Search Options` one can specify the string of text that must be present. That is, gnome-find provides this option as a shortcut to choosing the `-exec` action with this command:

   `grep -l "Look for this text" {} ;`

4. Please refer to the man page for details about the `grep` command.

### Commands which require user input (from the keyboard)

1. In some cases, gnome-find may execute a command which requires user input. That is, gnome-find will prompt the user for input, and the user must enter the input from the keyboard.
2. gnome-find does not intentionally ask for input. Rather, it is simply the command/option itself which needs it.
3. For example, if one needed to delete a bunch of files and some of them are read-only, the following GNU "find" command will prompt the user for input when a read-only file is encountered:

   `find . -exec rm {} \;`

   This is the nature of the `rm` command. In order for it not prompt and delete the file, `rm -f` needs to be specified.

4. Prompting may cause problems for gnome-find. If gnome-find was launched/executed from the command line, prompting will occur from the command line where gnome-find was started. However, if gnome-find was launched/executed not from the command line (e.g., from a GUI menu or another application), gnome-find will appear to hang since a command is prompting and expecting input, but there is no way to give it input other than from the command line.
5. Care must be taken for commands which may prompt the user for input. The best way to avoid this is to specify the "force" option which is found in most commands. e.g., `cp -f`, `mv -f`, and `rm -f`. Obviously, this can be dangerous as well. You have been warned.
6. The `-ok` action also falls into this category.

### Manually specifying a search

1. As powerful and flexible as the dialog for "Advanced Search Options" might be, there are still some things which can only be done on the command line. Consequently, gnome-find provides the option for manually specifying a search.
2. By clicking on the "Manual" toolbar button on the main window, a dialog pops up where you can enter your own, custom, search command. Here, simply type in the command as if you were typing it in from the command line, including starting the command with `find`.
3. WARNING! If you make a mistake in the command syntax (e.g., specifying an invalid option), gnome-find will abort and exit. This is a current limitation in its error handling since the typical way options are specified in gnome-find is through the graphical interface, which should never make mistakes in the syntax.

Last updated on June 25th, 2000 by Andy Kahn.
© 2000 Andy Kahn. All rights reserved.