Linux 在终端输入空字符

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7572801/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-05 06:22:36  来源:igfitidea点击:

Type null character in terminal

linuxtextterminal

提问by functionalCode

Is there a way to type the null character in the terminal?

有没有办法在终端中输入空字符?

I would like to do something like:

我想做类似的事情:

this is a sentence (null) test123

回答by tjarratt

Apparently you can type this character with ^@ on some character sets. This wikipedia article on the null charactermay be helpful.

显然,您可以在某些字符集上使用 ^@ 键入此字符。这篇关于空字符的维基百科文章可能会有所帮助。

回答by Oskar N.

$ echo -e "this is a sentence 
$ echo -e "this is a sentence ##代码## test123" | cat --show-nonprinting
this is a sentence ^@ test123
test123" this is a sentence test123

The null here ^^ IS NOT visible

The null here ^^ IS NOT visible

##代码##

But it IS here ^^

But it IS here ^^

But maybe you did not want this for a script?

但是也许您不希望将其用于脚本?

回答by AXE Labs

As with the abort command (Ctrl-C), in most terminals just hit Ctrl-@(with the use of Shifton my keyboard).

与 abort 命令 ( Ctrl- C) 一样,在大多数终端中只需点击Ctrl- @Shift在我的键盘上使用)。

回答by unode

In Linux, any special character can be literally inserted on the terminal by pressing Ctrl+vfollowed by the actual symbol. nullis usually ^@where ^stands for Ctrland @for whatever combination on your keyboard layout that produces @.

在 Linux 中,任何特殊字符都可以通过按Ctrl+v后跟实际符号来直接插入到终端上。null通常是^@其中^代表Ctrl,并@为在产生你的键盘布局什么组合@

So on my keyboard I do: Ctrl+vfollowed by Ctrl+Shift+@and I get a ^@symbol with a distinguished background color. This means it's a special character and not just ^and @typed in.

所以在我的键盘上我这样做:Ctrl+v后跟Ctrl+ Shift+@我得到一个^@具有独特背景颜色的符号。这意味着它是一个特殊的角色,而不仅仅是^@中键入。

Edit:Several years later and a few input variations implemented by different terminals using keyboard layouts that require pressing Shiftto access @.

编辑:几年后,不同终端使用需要按下Shift才能访问的键盘布局实现了一些输入变化@

  • Ctrl+vfollowed by Ctrl+Shift+@
  • Ctrl+vfollowed by Shift+@withoutreleasing Ctrl.
  • Ctrl+Shift+vfollowed by @withoutreleasing Ctrl+Shift.
  • Ctrl+Shiftrelease Shiftand re-press Shiftkeeping both Ctrl+Shiftpressed followed by vand finally @. Seen in some terminals that implement a special input on Ctrl+Shift.
  • Ctrl+v后跟Ctrl+ Shift+@
  • Ctrl+v后跟Shift+@释放Ctrl.
  • Ctrl+ Shift+v其次@,而不释放Ctrl+ Shift
  • Ctrl+Shift释放Shift并重新按下,Shift同时按下Ctrl+和最后。在一些在+上实现特殊输入的终端中可以看到。Shiftv@CtrlShift