Type null character in terminal

前端 未结 4 2024
深忆病人
深忆病人 2021-01-04 04:32

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
4条回答
  •  离开以前
    2021-01-04 05:01

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

    So on my keyboard I do: Ctrl+v followed 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.

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

    • Ctrl+v followed by Ctrl+Shift+@
    • Ctrl+v followed by Shift+@ without releasing Ctrl.
    • Ctrl+Shift+v followed by @ without releasing Ctrl+Shift.
    • Ctrl+Shift release Shift and re-press Shift keeping both Ctrl+Shift pressed followed by v and finally @. Seen in some terminals that implement a special input on Ctrl+Shift.

提交回复
热议问题