-1

I saw this line of code the other day and I didn't know exactly what is this - or when to use it. This is a simple code and from what I understood is that - takes the piped output and treats it as an argument of paste (correct me if I'am wrong)

seq $size | paste - $file

My question is when can we use this and is there another way to do the same thing? Thanks,

Const
  • 131
  • 2
  • 15
  • It's not a shell-specific thing, it's understood by some programs (including `paste`) to mean "use standard input rather than a file". – Tom Fenech Oct 11 '17 at 10:06

1 Answers1

1

This is documented in the man page for paste which says:

  With no FILE, or when FILE is -, read standard input.

That is, paste expects you to give it a filename, but you can instead give it a single - instead, which paste will interpret as it should read data from stdin , your pipe in this case, instead of opening a file and read data from that file.

nos
  • 223,662
  • 58
  • 417
  • 506