I got access to only Busybox 1.31.1
I originally wanted to remove the current working directory of my output (the single dot).
Example:
/prueba$ ls
uno dos tres
When I:
$ busybox find .
.
./uno
./dos
./tres
That's easily done with either:
busybox find . -not -path .
busybox find . -mindepth 1
Now, what I tried before is:
busybox find . -exec sh -c ' readlink -f "$1" | tail -n +2 ' sh {} \;
Which prints nothing. If verbose output is activated:
==> standard input <==
==> standard input <==
==> standard input <==
==> standard input <==
==> standard input <==
Completely different output if the line address is one:
busybox find . -exec sh -c ' readlink -f "$1" | tail -n +1 ' sh {} \;
==> standard input <==
/tmp/prueba
==> standard input <==
/tmp/prueba/tres
==> standard input <==
/tmp/prueba/dos
==> standard input <==
/tmp/prueba/uno
What's going on?
-mindepth 1
, not-maxdepth 1
, since the.
given on the command line is at depth 0. But is there a particular reason to usetail
and not the two ways you already have for removing.
from the output offind
? – ilkkachu Sep 09 '21 at 14:14find . -not -path . -exec ...
should work too. – ilkkachu Sep 12 '21 at 10:35-not
is non-standard, better to use!
which is standard complaint. Any literature work you can recommend to know the "right" way? – abacox Sep 13 '21 at 00:10!
is the standard one. Though just based on the man pages, the GNU, FreeBSD, OpenBSD and Busybox versions support-not
too. (Plus-and
and-or
which are similarly nonstandard variants of-a
and-o
.) In this case, the GNU manpage even mentions those are not POSIX compliant. The specification is online too, but as you might guess with a standard, it's not always the most fluent read. – ilkkachu Sep 13 '21 at 07:44