3

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
  • Can you explain it better? Commented May 13, 2014 at 15:43
  • When you used in the echo statement double-quotes surrounding the $'...' inhibited the expansion. Commented May 13, 2014 at 19:47

2 Answers 2

3

Try like this,

~$ printf %76s |tr " " "a"; echo "$'\x14\x84\x04\x08'"
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa$'\x14\x84\x04\x08'
Sign up to request clarification or add additional context in comments.

1 Comment

You can also dispense with the echo: printf '%76s\x14\x84\x04\x08' | tr ....
0

¿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')

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.