Odpowiedzi:
Przegapiłeś tylko jeden symbol =)
ssh user@socket command < /path/to/file/on/local/machine
scpwcześniej.
/dev/stdinlub -. Może działać lub nie ( /dev/stdinjest plikiem, ale jego szukanie zakończy się niepowodzeniem)
Jednym ze sposobów, który działa niezależnie od polecenia, jest udostępnienie pliku na zdalnym komputerze za pośrednictwem zdalnego systemu plików. Ponieważ masz połączenie SSH:
# What if remote command can only take a file argument and not read from stdin? (1_CR)
ssh user@socket command < /path/to/file/on/local/machine
...
cat test.file | ssh user@machine 'bash -c "wc -l <(cat -)"' # 1_CR
Jako alternatywę dla bashzastępowania procesów <(cat -)lub < <(xargs -0 -n 1000 cat)(patrz poniżej) możesz po prostu użyć xargsi catprzesłać zawartość określonych plików wc -l(która jest bardziej przenośna).
# Assuming that test.file contains file paths each delimited by an ASCII NUL character \0
# and that we are to count all those lines in all those files (provided by test.file).
#find . -type f -print0 > test.file
# test with repeated line count of ~/.bash_history file
for n in {1..1000}; do printf '%s\000' "${HOME}/.bash_history"; done > test.file
# xargs & cat
ssh localhost 'export LC_ALL=C; xargs -0 -n 1000 cat | wc -l' <test.file
# Bash process substitution
cat test.file | ssh localhost 'bash -c "export LC_ALL=C; wc -l < <(xargs -0 -n 1000 cat)"'