Wie werden Argumente aus mehreren Pipes übergeben?
command1 | command2 outputOfcommand1 | command3 outputOfcommand1 outputOfcommand2
Was ich genauer versuche, ist, ein Verzeichnis im Container aufzulisten, die zuletzt erstellte Datei abzurufen und auf den Hostcomputer zu ziehen. Jetzt verwende ich
sudo ls -t /var/snap/lxd/common/lxd/containers/con1/rootfs/home/usr1/Downloads | head -n 1 | xargs -I{} sudo mv /var/snap/lxd/common/lxd/containers/con1/rootfs/home/usr1/Downloads/{} .
. Der Pfad wurde hier zweimal angezeigt und ich möchte die Anzahl auf ein Mal reduzieren.
Antwort1
Es sieht so aus, als ob Sie eine Befehlsersetzung und keine Pipes benötigen:
outputOfcommand1=$(command1)
outputOfcommand2=$(command2 "$outputOfcommand1")
command3 "$outputOfcommand1" "$outputOfcommand2"