当我在Linux终端CLI上做do表时,如下所示。
hive -e "desc hive_db.hive_table"我得到以下输出
date string
entity string
key int
id string
direction string
indicator string
account_number string
document_date string现在,我想在执行之前将输出重定向到一个文件,我希望删除每个字段之间的空格,并且在它们之间只有一个空格。
预期产出低于
date string
entity string
key int
id string
direction string
indicator string
account_number string
document_date string我试过如下所示
hive -e "desc hive_db.hive_table" | tr -s " " > abc.txt我得到的输出是
date string
entity string
key int
id string
direction string
indicator string
account_number string
document_date string我得到的输出是一个接近的输出,但是在每一行的每个字段之间都有one space and one tab
我怎样才能实现我想要的?
发布于 2019-05-26 22:10:59
尝试:
hive -e "desc hive_db.hive_table" | sed -E 's/[[:space:]]+/ /' > abc.txt[[:space:]]+匹配任意类型的空白(制表符、空白或其他包括任何unicode定义的空白)中的一个或多个。s/[[:space:]]+/ /将空白序列替换为单个空白。
https://stackoverflow.com/questions/56317712
复制相似问题