find文件夹以及其中有我的string的文件名?

我需要find文件夹名称以及其内容中包含我的string的文件名称。 我在这个目录“ /data/queue/data ”,我有很多文件夹在同一目录和每个文件夹内,我有各种文件。

我想运行一个命令,它可以find我的文件夹名称和文件名,其中有一个特定的string,如“ badezimmer ”在其内容中。 什么是最快的方法来做到这一点?

下面是这个目录中的文件夹“ /data/queue/data ”,这些文件夹中的每一个都有不同的文件。

 david@machineA:/data/queue/data$ ls -lrth drwxr-xr-x 2 david david 12K Apr 11 18:58 1428800400 drwxr-xr-x 2 david david 12K Apr 11 19:58 1428804000 drwxr-xr-x 2 david david 12K Apr 11 20:58 1428807600 

我只想从这个目录运行一个命令 – “/ data / queue / data”,如果他们的内容中有我的string,可以打印出该文件夹的文件夹名称和文件名。

 david@machineA:/data/queue/data$ some command to find the folder and files which has my string. 

正如所讨论的,以下将做你想要的:

 grep -rl 'badezimmer' /data/queue/data 

grep(1)的手册页:

 -l, --files-with-matches Suppress normal output; instead print the name of each input file from which output would normally have been printed. The scanning will stop on the first match. -r, --recursive Read all files under each directory, recursively, following symbolic links only if they are on the command line. This is equivalent to the -d recurse option.