Score:0

trailing "-" as a placeholder

jp flag

If reading this I then understanding, that you can set the stdin to be piped to the command as parameter to a placeholder "-"

like:

cat <<EOF | printf -  
hello  
new line
EOF

But it only prints "%"?

fo flag
`printf` doesn't read from stdin. This smells like an XY problem: what are you really trying to accomplish?
jp flag
To understand “-“
fo flag
The hyphen meaning is specific to each command that implements it, but generally, yes, it is a placeholder for "read stdin as a file". `printf` does not implement it. But `diff` does. So does `grep`.
ph flag
Even commands that interpret `-` as a placeholder for stdin only do so if it occurs where they expect an input filename to be (and generally interpret it as stdout if it's where an output filename should be). The first argument to `printf` is a format string, not a filename, so interpreting it as stdin doesn't make any sense.
jp flag
I guess “/dev/fd/1” would be the same for any command supporting “-“ or file input.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.