Encapsulating HiveF commands with shell scripts in hive
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.