简体   繁体   English

用printf以bash导出不起作用

[英]export in bash with printf doen't work

I exported: 我出口了:

export FMTSTR="%2\$n'printf "\xc0\xf2\x03\x42";'"

and I want to see the result: 我想看看结果:

env | grep FMTSTR
FMTSTR=%2$n'printf xc0xf2x03x42;'

but this is not what I want...The result must be : 但这不是我想要的...结果必须是:

‫‪FMTSTR=%2$nTB‬‬

Could you possibly tell me what the problem is? 你能告诉我问题是什么吗? secondly can I use python instead of printf? 其次,我可以使用python代替printf吗? like this: 像这样:

export FMTSTR="%2\$n $(python -c 'print "\xc0\xf2\x03\x42"')"

when I use python the result is: 当我使用python时,结果是:

FMTSTR=%2$n ��B

why? 为什么? please give me a help in these two questions. 请在这两个问题上给我帮助。

thank you... 谢谢...

This is not exactly correct (due to the nature of your question), but I feel you may have better luck using this: 这并不是完全正确的(由于您问题的性质),但是我觉得使用此方法可能会更好:

export FMTSTR=`python -c 'print "%2$n\xc0\xf2\x03\x42"'`

Now, the \\xc0\\xf2\\x03 has no ascii equivalent. 现在, \\xc0\\xf2\\x03没有ascii等效项。 I'm not sure how you're expecting the output TB. 我不确定您对TB的期望如何。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM