Trying to do this within a bash script using sed regex on macos. I have a file with directory listings of an external drive.

```
/Volumes/WD/A/Some Learning/Learning Is Great/
/Volumes/WD/A/Some Deeper/Learning Is Great/Another Learning Opportunity/
/Volumes/WD/B/More Things Here/Great Learning/
/Volumes/WD/B/More Things/

```

I want to search and return the top-most directory matching various patterns. If you search for 'Learning' the output should be:

```
/Volumes/WD/A/Some Learning/
/Volumes/WD/A/Some Deeper/Learning Is Great/
/Volumes/WD/B/More Things Here/Great Learning/

```