1、在你的linux上建一个test.sh文本
vi test.sh
2、敲回车
3、按i进入编辑模式,然后输入代码(下面只是我的demo)
#!/bin/bash
hive -e "select a.appcode,b.province,b.city,count(distinct a.open_id ) as member
from
(select upper(mac) as mac,appcode,open_id from table1 where day='2019-10-23' and isnew=1 and appcode in (1026,1028) ) as a
left join
(select upper(mac) as mac,province,city from table2 where day='2019-10-23') as b
on a.mac = b.mac
group by a.appcode,b.province,b.city;" >> /home/zou/tt.txt
3、先按Esc建,然后按住Shift再按":"接着输入wq就保存退出了
4、执行命令sh test.sh
5、执行完了就可以去/home/zou/tt.txt这个路径找文件了
6、输入sz + 文件路径(将文本拉取到电脑本地)
从hive查询数据追加至文本(在linux操作)
最新推荐文章于 2022-03-31 18:21:33 发布