命令 hive -e " set hive.cli.print.header=true; #将表头输出 select * from data_table where some_query_conditions " | sed 's/[\t]/,/g' > hhd.csv set hive.cli.print.header=true将表头输出:sed 's/[\t]/,/g' 将\t替换成,> 将shell里打印的内容输出到文件
#!/bin/bash #用途: #.当前目录的txt文件批量转csv #.制表符转逗号分隔符 #.NULL去除 #.删除WARN警告 for i in `ls ./*.txt` do sed -e 's/\t/,/g' -e 's/NULL//g' -e '/^WARN:/d' $i >$i.csv done