I was passed the following, which does a dry run of the creation of a kubernetes secret from an appsettings.json file, which is then piped to a kubernetes apply. I think that the -f will take the filename of the --dry-run created secret and use that when applying the secret, but I'm wondering if the trailing - has any significance or if it's just a typo?

kubectl create secret generic test --from-file=appsettings.json --dry-run -oyaml | kubectl apply -f -


2 Answers 2


The - character can be understood as a placeholder for the output of the command which is piped ( using | character ). By using it, we instruct very specifically the subsequent command ( to which the output is piped ), where the standard output of the first command ( it's execution result ) should be placed, in other words how it should be taken or parsed.

So rather than piping the result of:

kubectl create secret generic test --from-file=appsettings.json --dry-run -oyaml

(which happens to be a yaml manifest)

directly to:

kubectl apply -f

which doesn't know what to do with such input (as it expects a file after -f flag), we indicate very precisely where it fits:

kubectl apply -f -

In this case, we instruct kubectl apply command that the piped output from the previous command should be taken instead of a file, which is expected after providing -f flag.

  • 4
    It is not a placeholder. It by Unix convention means "read from standard input" Commented Nov 26, 2020 at 10:16

The - is a parameter to the -f option, which means to accept input from standard input instead of a named file. Hundreds of UNIX/Linux commands have options like this.

  • ... and this is particularly useful for commands that would not use stdin as input by default Commented Nov 25, 2020 at 20:45
  • 1
    Just to add to this, but its also there to say "this is the end of the arguments list, what comes next is content" just incase the first few characters in that content resemble more arguments.
    – Moo
    Commented Nov 26, 2020 at 0:36
  • 5
    Don't confuse - (single dash) with -- (double dash). Single dash is often use as this answer says, for directing an application to use stdin. Double dash works as the comment says, telling the application not to consider any remaining arguments as options. Works for files that start with dashes, or when an application might pass on further arguments to whatever it is running (for example, a scripting language that reads command arguments.)
    – Andrakis
    Commented Nov 26, 2020 at 6:24
  • Note that this is not standard Unix functionality at the kernel layer. The convention is explicitly coded in each of the many commands. Commented Nov 26, 2020 at 10:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .