6

I am trying to find all the files that contain a search term:

grep -lir "Search" .

and pipe that into sublime:

grep -lir "Search" . | subl

but all this does is open a single file in sublime containing all the search results file paths as lines in the file. What I would like is to open each of those files as a sublime project.

2 Answers 2

7

Using the command subl $(grep -lir "Search" .) will give you the expected output. The $(command) expands with the output of the command and gives it as input to the sublime command. More information can be found in the Bash Manual.

4

Just use xargs:

grep -lir "Search" . | xargs subl

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .