Usage of '-' after pipe

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,

1 answer

  • answered 2017-10-11 10:02 nos

    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.