0

Currently in atom I can search for a string in my project, but is there a way to search for a string in my projects, then search for a string in those files found in the first search?

I want to be able to find all uses of a function in a class, but the problem is that the class can have any name in files(thank you Javascript). So I know which files import my class based on the file location which gets imported, but I don't have any way of searching those results for the string 'getOrder'. For example I would like to be able to do the following:

  • search for the string 'meals/meals'
  • get a list of file names
  • use those file names and search for the string '.getOrder'

I think this is doable with grep, but I am no master of grep. I tried that route and failed.

Dan Lowe
  • 51,713
  • 20
  • 123
  • 112
Samuel Thompson
  • 2,429
  • 4
  • 24
  • 34

1 Answers1

1

You can grep a grep by feeding into the grep command with $():

https://unix.stackexchange.com/questions/20262/how-do-i-pass-a-list-of-files-to-grep

and this guy showed me how to get a list of files that contain the string I need:

How do I find all files containing specific text on Linux?

which gives you

grep createOrder $(grep -rnwl './' -e 'meals/meals')
Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Samuel Thompson
  • 2,429
  • 4
  • 24
  • 34