如何在不键入任何 space 和在 Linux Bash shell 中引用的情况下打印 space 字符?
How to print a space char without type any space and quote in Linux Bash shell?
如何在不键入任何 space 并在 Linux Bash shell?
中打印 space 字符
通常,人们可以通过这个
回显一个space字符
➜ ~ echo " "
# output a space character here
或
➜ ~ print " "
# output a space character here
或更进一步
➜ ~ echo \u0020
# output a space character here
但所有这些脚本,在输入命令时至少需要输入一个space字符。
我的问题是:如何打印 space 字符 而无需 输入 space
字符并引用 "
/ '
中的字符 Linux Bash shell?
可能是伪代码
➜ ~ emptychar
# output a space character here
避免 spaces 和反斜杠
IFS=:;cmd=base64:-d;$cmd<<<IA==
...使用 hexdump 证明这会在输出中产生 space:
$ IFS=:;cmd=base64:-d;$cmd<<<IA== | hexdump -C
00000000 20 | |
00000001
避免空格
使用IFS
设置一个non-space字符作为字段分隔符可以在这里利用:
IFS=:;var=printf:%b:\x20;$var
同样,演示输出:
$ IFS=:;var=printf:%b:\x20;$var | hexdump -C
00000000 20 | |
00000001
如何在不键入任何 space 并在 Linux Bash shell?
中打印 space 字符通常,人们可以通过这个
回显一个space字符➜ ~ echo " "
# output a space character here
或
➜ ~ print " "
# output a space character here
或更进一步
➜ ~ echo \u0020
# output a space character here
但所有这些脚本,在输入命令时至少需要输入一个space字符。
我的问题是:如何打印 space 字符 而无需 输入 space
字符并引用 "
/ '
中的字符 Linux Bash shell?
可能是伪代码
➜ ~ emptychar
# output a space character here
避免 spaces 和反斜杠
IFS=:;cmd=base64:-d;$cmd<<<IA==
...使用 hexdump 证明这会在输出中产生 space:
$ IFS=:;cmd=base64:-d;$cmd<<<IA== | hexdump -C
00000000 20 | |
00000001
避免空格
使用IFS
设置一个non-space字符作为字段分隔符可以在这里利用:
IFS=:;var=printf:%b:\x20;$var
同样,演示输出:
$ IFS=:;var=printf:%b:\x20;$var | hexdump -C
00000000 20 | |
00000001