So I'm trying to print a string as a argument to a program in the terminal. However, my command doesn't seem to match the string, which I need. The string I need to print is:

aaaaa$'\x14\x84\x04\x08'

My command:

`printf 'a%.0s' {1..76}; echo "$'\x14\x84\x04\x08'"`

Am I just making a stupid mistake?

有帮助吗?

解决方案 2

¿Something like this?

 `printf "%76s"; echo "$'\x14\x84\x04\x08'"`

If do you want to print the hex characters:

 `printf "%76s"; echo $'\x14\x84\x04\x08'`

Is recommended to use the dollar sign and parentheses instead of backticks:

 $(printf "%76s"; echo "$'\x14\x84\x04\x08'")

Or

 $(printf "%76s"; echo $'\x14\x84\x04\x08')

其他提示

Try like this,

~$ printf %76s |tr " " "a"; echo "$'\x14\x84\x04\x08'"
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa$'\x14\x84\x04\x08'
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top