Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Encapsulating HiveF commands with shell scripts in hive

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

There is a hive-e command in hive that can pass parameters, but when there are too many hql statements, the whole shell script will appear messy. Of course, some people may say that hive-f can directly call a file,bingo, but there is still a big defect, that is, this cannot pass parameters, which is intolerable in actual work. So I came up with the idea of encapsulating a command HiveF, which can be passed directly into file and parameters. In fact, the implementation is very simple, let's share the code. Of course, it's not perfect. Let's throw a brick to attract jade.

#! / bin/bash

. / etc/profile

Cat $1 > $1.tmp

For arg in "$@"

Do

Echo "arg" $arg

Flag= `echo $arg | grep'-'`

If [$arg! = $1]; then

If [$flag]; then

Tmp= `echo $flag | sed Compact / `

Else

Sed-I s / {$tmp} / $arg/g $1.tmp

Echo "nothing"

Fi

Fi

Done

Hive-f $1.tmp

Rm-f $1.tmp

I hope I can help you again.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report