Saturday, February 5, 2022

[SOLVED] How to send the output of this command: find ./ -type f -exec grep -H 'String' {} \; to a file?

Issue

Somewhere in here someone shared this cool way to find stuff in unix:

find ./ -type f -exec grep -H 'string to be searched' {} \;

And I was wondering how to send the output of it to a file.

I tried the basic >> something.log but it seems to ignore it, perhaps because of the last part of the command {} \;

Could you help me to achieve this?

Thank you in advance.


Solution

On Ubuntu, it works perfectly using the standard way you mentioned, just write the command as following:

find ./ -type f -exec grep -H 'string to be searched' {} \; > newFile.txt


Answered By - Yazid Erman
Answer Checked By - Marie Seifert (WPSolving Admin)