recursive lookup

To lookup a string or file name recursively in every file, directory and subdirectory starting at a current position, use grep -r. In the example, the command found instances of journald.conf in the file named a and in the .bash_history file:

user1@rhel10-vm2:~$ pwd
/home/user1
user1@rhel10-vm2:~$ ls -l
total 152
-rw-r--r--. 1 user1 user1   2470 Aug 21 19:40 a
-rw-r--r--. 1 user1 user1 150459 Aug 19 18:13 q
drwxr-xr-x. 2 user1 user1      6 Aug 21 19:49 test
user1@rhel10-vm2:~$ 
user1@rhel10-vm2:~$ grep -r journald.conf
.bash_history:ls /etc/systemd/journald.conf
.bash_history:find /etc -mindepth 1 -name "journald.conf" -type f 2>/dev/null
.bash_history:find /  -mindepth 1 -name "journald.conf" -type f 2>/dev/null
.bash_history:ls /usr/lib/systemd/journald.conf
.bash_history:cat /usr/lib/systemd/journald.conf
.bash_history:find / -mindepth 1 -name "journald.conf" -type f 2>/dev/null
.bash_history:find / -maxdepth 4 -name "journald.conf" -type f 2>/dev/null
.bash_history:cat /usr/lib/systemd/journald.conf
.bash_history:systemd-analyze cat-config systemd/journald.conf
.bash_history:cat /run/lib/systemd/journald.conf
.bash_history:cat /usr/lib/systemd/journald.conf
a:# journald.conf/usr/lib/systemd/journald.conf
a:# the /etc/systemd/journald.conf.d/ directory. The latter is generally
a:# Use 'systemd-analyze cat-config systemd/journald.conf' to display the full config.
a:# See journald.conf(5) for details.
user1@rhel10-vm2:~$ 

To return only the first occurrence of the files which contain the search string, instead of returning the lines where the string appears, use grep -l: