In a batch file, I can send the results from grep to a file like this:

```
grep -o -P -f search_text.txt text_file.txt >outputfile.txt

```

But I don't want the result to go to a file. I want the result to be stored in a variable that I can use later in the batch file. I want to do this:

```
grep -o -P -f search_text.txt text_file.txt >my_variable

```

But of course that doesn't work. How can I get grep results assigned to a variable?