We can find the full absolute path of a destination file using find keyword. In my case, I need the list of all immediate next directory to my given location which can lead me to my program log file named foo.log
For example, some of the paths may be:
given-location/alpha/beta/gamma/foo.log
given-location/apple/banana/foo.log
For the above case, I need a list/array/vector anything like ['alpha', 'apple']
as my result as it contains all the possible immediate next folder to reach the destination file.
I'm new to Linux tools. I know, I can always create a brute force solution as I have the absolute-path as well as the given-path, but any optimized/better solution or any hint/idea in the right direction will do!
I don't want the first distinct folder, just the immediate folder to the given-location.
My brute force approach:
result={}
for all the Absolute-path which can reach foo.log:
Suffix-path = (Absolute-path - given-path)
Append the Suffix-path[0] to result