답변:
당신은 하나의 기호를 놓쳤다 =)
ssh user@socket command < /path/to/file/on/local/machine
scp이전 에 복사해야합니다 .
/dev/stdin주거나 시도 할 수 있습니다 -. 작동하지 않을 수도 있고 작동하지 않을 수도 있습니다 ( /dev/stdin파일이지만 파일을 찾는 데 실패합니다)
명령에 관계없이 작동하는 한 가지 방법은 원격 파일 시스템을 통해 원격 시스템에서 파일을 사용할 수있게하는 것입니다. 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
대체 bash프로세스 <(cat -)또는 < <(xargs -0 -n 1000 cat)(아래 참조)에 대한 대안으로 지정된 파일의 내용을 사용 xargs하고 cat파이프로 wc -l이식 할 수 있습니다 (더 이식성이 뛰어납니다).
# 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)"'