Limitations of the find Utility

Learn about the pros and cons of -exec parameter of find utility.

We'll cover the following

The -exec parameter

The find utility has the -exec parameter. It calls the specified command for each found object. This behavior resembles a pipeline: find passes its result to another program. These two mechanisms look similar, but their internals differs. We choose the appropriate one depending on our task.

Let’s look at how the find utility performs the -exec action. The utility has a built-in interpreter. When it receives the -exec action on input, it calls the specified program there. The interpreter passes to the program whatever the find utility has found. Note that Bash is not involved in the -exec call. Therefore, we cannot use the following Bash features there:

  • built-in Bash commands
  • functions
  • pipelines
  • stream redirection
  • conditional statements
  • loops

After connecting, let’s try to run the following command in the terminal below:

find ~ -type f -exec echo {} \;

Get hands-on with 1400+ tech skills courses.