相关疑难解决方法(0)

在制表符分隔文件上读取bash,而不会删除空字段

我正在尝试在bash中读取多行制表符分隔文件.格式是预期的空字段.不幸的是,shell正在将彼此相邻的字段分隔符折叠在一起,如下所示:

# IFS=$'\t'
# read one two three <<<$'one\t\tthree'
# printf '<%s> ' "$one" "$two" "$three"; printf '\n'
<one> <three> <>
Run Code Online (Sandbox Code Playgroud)

...而不是期望的输出<one> <> <three>.

这可以解决而不诉诸单独的语言(如awk)?

bash

11
推荐指数
3
解决办法
2万
查看次数

标签 统计

bash ×1