Hi Marc, Does this do what you want? I've omitted the call to `run` and used mostly IO::Path calls instead:
~$ echo "/Users/admin/logs" | raku -e 'for lines.IO -> $a is copy {$a.Str.say; repeat {$a.=parent andthen $a.Str.say;} until $a eq $*SPEC.rootdir;};' #returns: /Users/admin/logs /Users/admin /Users / Note, above won't actually check if the given directory is valid--it only checks the parents. To check a given directory first, try the following: ~$ echo "/Users/admin/bogus_dir/" | raku -e 'for lines.IO -> $a is copy {if $a.d {$a.Str.say; repeat {$a.=parent andthen $a.Str.say;} until $a eq $*SPEC.rootdir}};' #returns nothing for `bogus_dir` HTH, Bill. On Mon, Sep 5, 2022 at 1:56 PM Marc Chantreux <m...@unistra.fr> wrote: > I love this one. I used uniq and run so the whole script can be run from > raku (except the xargs ls avoid the ARG_MAX error) > > <<. raku -e 'run < ls -lUd >, unique map {(.IO, *.parent …^ > "/")>>.Str.Slip}, lines' > /var/log/messages > /var/log/auth.log > > regards > > -- > Marc Chantreux > Pôle de Calcul et Services Avancés à la Recherche (CESAR) > http://annuaire.unistra.fr/p/20200 >