Forrest logo
back to the fswatch tool

fswatch:tldr:d75fd

fswatch: Print the absolute paths of the changed files.
$ fswatch ${path-to-directory} | xargs -n 1 -I {} echo {}
try on your machine

This command involves two parts:

  1. fswatch ${path-to-directory}: This part watches for changes in the specified directory ${path-to-directory} using the fswatch command. When any change occurs (such as file creation, modification, or deletion), it outputs the name of the changed file or directory to the standard output.

  2. xargs -n 1 -I {} echo {}: This part takes the output from fswatch and executes the echo {} command for each file or directory name received as input. Here's what each flag does:

    • -n 1: Specifies that xargs should execute the command (echo {}) once for each input. This ensures that the command is run separately for each file or directory name.
    • -I {}: Replaces occurrences of {} in the command with each input from stdin. In this case, it replaces {} with the name of the file or directory received from fswatch.
    • echo {}: The command that is executed for each input. In this case, it simply prints the name of the file or directory to the terminal.

In summary, this command monitors the specified directory for any changes and then prints the names of the changed files or directories as they occur.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the fswatch tool