How can I search the filesystem only for the first positive match in a path? For example, searching for foo:
./some/foo/long/foo/path
./another/foo/long/foo/path
should return:
./some/foo/
./another/foo/
I think the find command should be able to do this, but I can't figure out which flags to use, obviously any other command that achieves the result would be fine.
./some/bar/long/foo/path, if./some/foo/exists. The previous answer would treadsomeas a "directory that contains name", sosomewould be "a match" and "without searching matches' subfolders" would mean we don't want to find./some/bar/long/foo. The current answer treatsfooas "a match" and it finds./some/bar/long/foo. – Kamil Maciorowski May 27 '21 at 08:55