0

Just wondering; is it possible to skip the cat in

some_command | ssh remote 'cat > outputfile'

? It feels like a UUOC.

Anthon
  • 78,313
  • 42
  • 165
  • 222
Fred Foo
  • 423
  • 4
  • 10

1 Answers1

4

No, you need something that reads its stdin and writes it to some file. cat is a good choice for that as it supports binary data and doesn't do anything fancy with its input so is small and efficient.

You could do:

... | ssh remote 'cp /dev/stdin outputfile`

But that would not be more efficient and would only work on systems that have /dev/stdin.

Stéphane Chazelas
  • 522,931
  • 91
  • 1,010
  • 1,501
  • Using `cp /dev/stdin` solves my problem, see https://unix.stackexchange.com/questions/712933/does-unix-have-a-command-to-read-from-stdin-and-write-to-a-file-like-tee-withou. Where I wanted to use `sudo cp /dev/stdin /etc/root-access-file`. Thanks! Feel free to answer that question with information. :-) – PatS Aug 08 '22 at 20:24