0

I am looking for a way to find all "info.plist"-files that contain "iphonesimulator" in my directory and all subdirectories.

I know that I can find all "iphonesimulator" via:

grep -ri "iphonesimulator" .

But that is not everything that I want. Is there a way to also filter for files? I tried with -f but that does not work.

Rüdiger
  • 893
  • 5
  • 27
  • 56
  • Do you mean you want to find the *names of the files* containing that string? Or do you mean you want to see all the *lines containing that string* in those files? – Mark Setchell Oct 13 '17 at 12:15
  • @MarkSetchell I want the Terminal to show me the directory to the files named info.plist (because there are quite a few of it) that contain the String "iphonesimulator". I need this because I have to replace them by "iPhoneOS" for the deploy – Rüdiger Oct 13 '17 at 12:44

1 Answers1

1

You can use the following:

find <root_directory> -name '<file_matching_pattern>' -exec cat {} \; -exec grep --colour -i 'text_matching_pattern' {} \;

For your particular example:

find / -name info.plist -exec cat {} \; -exec grep --colour -i '*iphonesimulator*' {} \;

or you can just ignore file name pattern and do it like this

Mark Setchell
  • 191,897
  • 31
  • 273
  • 432
Niko
  • 616
  • 4
  • 20