سؤال

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