ble*_*man 4 unicode bash ascii cut
可以cut
在带¬
分隔符的bash中使用吗?
这个问题是这里讨论的主题的扩展.对该链接的目标的一种解释是使用在人类文本中找不到(或很少发现)的分隔符.假设我们选择'Not Sign'(¬
)作为分隔符.我的问题是关于使用cut
所述分隔符来拉取文件的特定列.
例如,假设我们使用¬
分隔符创建文件.文件prac.txt可能如下所示:
$cat prac.txt
"Billy""Car"¬"Red"¬"Garage"¬"3"
"Rob"¬"Truck"¬"Blue"¬"Street"¬"14"
Run Code Online (Sandbox Code Playgroud)
以下过程会产生错误:
$cut -d'¬' -f1 prac.txt
cut: the delimiter must be a single character
Try `cut --help' for more information.
Run Code Online (Sandbox Code Playgroud)
正确的输出是:
"Billy"
"Rob"
Run Code Online (Sandbox Code Playgroud)
来自python的可能有用的信息:
import unicodedata
>>>unicodedata.lookup('Not sign')
u'\xac'
Run Code Online (Sandbox Code Playgroud)
可能有用的字符转换链接.
我的猜测是该-d
标志使用了一些我尚未尝试过的"¬"表示,否则它仅适用于单个ascii字符.在此先感谢您的帮助.