Re: recursive find in current and parent etc until an item is found

2020-04-13 Thread Bernhard Voelker
On 2020-04-12 21:12, Peng Yu wrote: > OK. So this will make sure `/d1/d2/d3` will not be searched multiple > times? Or it is still searched when `/d1/d2`, `/d1` or `/` is > searched? Well, it's easy to go up the tree and using the -prune option to omit the already searched directories. ---8<---8<

Re: recursive find in current and parent etc until an item is found

2020-04-12 Thread Peng Yu
OK. So this will make sure `/d1/d2/d3` will not be searched multiple times? Or it is still searched when `/d1/d2`, `/d1` or `/` is searched? On 4/12/20, Bernhard Voelker wrote: > On 2020-04-11 12:19, Peng Yu wrote: >> Recursive also means subdirectories, sub subdirectories, etc. > > ah, so you wa

Re: recursive find in current and parent etc until an item is found

2020-04-12 Thread Bernhard Voelker
On 2020-04-11 12:19, Peng Yu wrote: > Recursive also means subdirectories, sub subdirectories, etc. ah, so you want to fall back for the search to the parent and all parent directories. E.g. if you are in /d1/d2/d3 then you want to search in /d1/d2/d3 falling back to /d1/d2 and /d1 and

Re: recursive find in current and parent etc until an item is found

2020-04-11 Thread Peng Yu
Recursive also means subdirectories, sub subdirectories, etc. On Sat, Apr 11, 2020 at 4:17 AM Bernhard Voelker wrote: > On 2020-04-10 19:29, Peng Yu wrote: > > On 4/10/20, Bernhard Voelker wrote: > >> ---8<---8<---8<---8<---8<---8<---8<---8<---8<---8<---8<--- > >> #!/bin/sh > >> > >> f="$1" \ >

Re: recursive find in current and parent etc until an item is found

2020-04-11 Thread Bernhard Voelker
On 2020-04-10 19:29, Peng Yu wrote: > On 4/10/20, Bernhard Voelker wrote: >> ---8<---8<---8<---8<---8<---8<---8<---8<---8<---8<---8<--- >> #!/bin/sh >> >> f="$1" \ >> && test -n "$f" \ >> || { echo "Usage: $0 FILE" >&2; exit 1; } >> >> p="." >> >> # Search until the parent is identical to the

Re: recursive find in current and parent etc until an item is found

2020-04-10 Thread Peng Yu
Thanks. I will need to search the parent directory recursively. Does this code only search whether a file is in a parent their parents, etc., but not recursively for a given ancestor? On 4/10/20, Bernhard Voelker wrote: > On 2020-04-10 16:09, Peng Yu wrote: >> Hi, >> >> I'd like to look for a fil

Re: recursive find in current and parent etc until an item is found

2020-04-10 Thread Bernhard Voelker
On 2020-04-10 16:09, Peng Yu wrote: > Hi, > > I'd like to look for a file by its name in the current directory. If > not found, go the the parent and look for it again. If not go up one > level again and look for it, ... until it is found (or until a given > level is reached). If the file is not f

recursive find in current and parent etc until an item is found

2020-04-10 Thread Peng Yu
Hi, I'd like to look for a file by its name in the current directory. If not found, go the the parent and look for it again. If not go up one level again and look for it, ... until it is found (or until a given level is reached). If the file is not found, return an error. The resulted path should