Bash 'printf' equivalent for command prompt?

Calum Murray picture Calum Murray · Mar 13, 2011 · Viewed 10.9k times · Source

I'm looking to pipe some String input to a small C program in Windows's command prompt. In bash I could use

$ printf "AAAAA\x86\x08\x04\xed" | ./program

Essentially, I need something to escape those hexadecimal numbers in command prompt.

Is there an equivalent or similar command for printf in command prompt/powershell?

Thanks

Answer

Keith Hill picture Keith Hill · Mar 13, 2011

In PowerShell, you would do it this way:

"AAAAA{0}{1}{2}{3}" -f 0x86,0x08,0x04,0xed | ./program