第一种,在bash中直接通过hive -e命令,并用 > 输出流把执行结果输出到制定文件
hive -e "select * from test.hour_rate2 where year='2019'" > /tmp/output_1.txt
第二种,在bash中直接通过hive -f命令,执行文件中一条或者多条sql语句。并用 > 输出流把执行结果输出到制定文件
hive -f /tmp/ > /tmp/output_3.txt
文件内容
use test;
select * from hour_rate2 where year = '2018';
select count(*) from hour_rate2;