How to type ^A in unix shell script/VI

守給你的承諾、 提交于 2020-01-14 12:54:07

问题


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


回答1:


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;
^^^^^^^^^^



回答2:


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.




回答3:


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




回答4:


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.



来源:https://stackoverflow.com/questions/27701714/how-to-type-a-in-unix-shell-script-vi

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!