出力なし: busybox find 。 -exec sh -c 'readlink -f "$1" | -exec sh -c 'readlink -f "$1" | tail -n +2 ' sh {} \;

出力なし: busybox find 。 -exec sh -c 'readlink -f

Busybox 1.31.1にのみアクセスできます。

最初は、出力の現在の作業ディレクトリ(単一点)を削除したかったのです。

例:

/prueba$ ls
uno dos tres

私は:

$ busybox find .
.
./uno
./dos
./tres

これは、次のいずれかの方法で簡単に実行できます。

busybox find . -not -path .
busybox find . -mindepth 1

今私が前に試したことは次のとおりです。

busybox find . -exec sh -c ' readlink -f "$1" | tail -n +2 ' sh {} \;

何も印刷しません。詳細出力が有効な場合:

==> standard input <==
==> standard input <==
==> standard input <==
==> standard input <==
==> standard input <==

行アドレスが1の場合、出力は完全に異なります。

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

どうなりますか?

ベストアンサー1

これ

-exec some command with parms {} \;

各ファイルに対してこのコマンドを一度に呼び出します。あなたの場合、readlink1行の出力が出力された後、最初の行を削除してtail -n +2何も残しません。これを使用すると、入力が出力にコピーされることをtail -n +1冗長に表現するだけです。cat

これをオーバーライドすると、tail -n +2次のように暗黙的なループの外側になります。

busybox find . -exec sh -c ' readlink -f "$1" ' sh {} \; | tail -n +2

期待した結果が得られるはずです。

コマンドの実行をバッチ処理することで、コマンドの効率を向上させることができます。

busybox find . -exec readlink -f -- {} + | tail -n +2

複数のファイルを取得するには、実行するコマンドが必要です。これにより、findはファイルごとに1回ではなく、ファイル名のバッファ全体がある場合にのみコマンドを実行するため、+findよりもコマンドを少なく実行できます。\;もちろん不要なものも削除しましたsh

おすすめ記事