How to type ^A in unix shell script/VI

2019-06-25 08:16发布

I am new to unix and writing script to extract data in delimited file format.

want to use ^A as delimiter , can you please suggest how to type/insert it

标签: shell unix vi
4条回答
做自己的国王
2楼-- · 2019-06-25 08:39

I think the answer is '\001', but I'm not a very experienced shell scripter.

Here is a link that helped:

http://docstore.mik.ua/orelly/unix/upt/ch45_35.htm

查看更多
我命由我不由天
3楼-- · 2019-06-25 08:48

Type Ctrl + V, then Ctrl + A.

According to your system configuration, you may need to type other key sequence. Check the output of stty -a, especially lnext:

$ stty -a | grep lnext
lnext = ^V; flush = ^O; min = 1; time = 0;
^^^^^^^^^^
查看更多
萌系小妹纸
4楼-- · 2019-06-25 08:48

In vi, you can generally type CTRL-V in insert mode, followed by another control character.

That's also true in the bash shell if you're in vi editing mode (entered with CTRL-K).

In emacs editing mode (usually entered by using the up arrow key), you would use CTRL-Q as a prefix command, before entering the character you want.

For example, here's my shell session showing the use of CTRL-VCTRL-A (which shows up as ^A):

pax> echo -n "^A" | od -b
0000000 001
0000001

You can see that the octal dump of the single character is indeed CTRL-A, or 001.

查看更多
仙女界的扛把子
5楼-- · 2019-06-25 08:51

You can type :h digraph-table to see the digraph-table text that describes the character. Then you can input Ctrl + K and the digraph line consponsed to your character.

查看更多
登录 后发表回答