Linux · March 29, 2023 0

How to redirect ‘find’ command output to a file in Linux?

Table of Content

To redirect the output of a ‘find’ command to a file in Linux, you can use the ‘> ‘ operator followed by the name of the file where you want to store the output.

For example, the following command will find all files in the ‘/path/to/directory’ directory and its subdirectories that have the ".txt" extension and store the output in a file named output.txt:

find /path/to/directory -type f -name "*.txt" > output.txt

You can also append the output to an existing file using the ‘>>’ operator. For example:

find /path/to/directory -type f -name "*.txt" >> output.txt

This will add the output of the ‘find’ command to the end of the file named output.txt.

%d bloggers like this: