[英]bash printf + echo string
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? 我只是犯了一个愚蠢的错误吗?
Try like this, 试试这样,
~$ printf %76s |tr " " "a"; echo "$'\x14\x84\x04\x08'"
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa$'\x14\x84\x04\x08'
¿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')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.