I have the following bash-script:
#!/bin/bash
printColored(){
echo -e "\e[0;"$2"m \t"$1" \e[0;37m"
}
printColored "Executing query with usual tables." 34
time hive -f query1.sql
printColored "Executing query with RCFile tables." 34
time hive -f query2.sql
It gives me the following output:
Executing query with usual tables.
...
a lot of output of hive command
...
real 1m8.928s
user 0m36.283s
sys 0m2.157s
Executing query with RCFile tables.
...
hive output again
...
real 1m9.376s
user 0m37.186s
sys 0m2.168s
How can I change my script if I need all hive output before echo and time output after it?
I.e. output must be in the following order:
...hive 1...
...hive 2...
Executing query with usual tables.
real 1m8.928s
user 0m36.283s
sys 0m2.157s
Executing query with RCFile tables.
real 1m9.376s
user 0m37.186s
sys 0m2.168s
If this is impossible, how can I eliminate hive output?
The output of bash's time command can be controlled with the TIMEFORMAT shell variable. To include your desired messages with the usual time information:
TIMEFORMAT=$'\nExecuting query with usual tables\nreal\t%3lR\nuser\t%3lU\nsys%3lS'
time hive -f query1.sql
TIMEFORMAT=$'\nExecuting query with RCFile tables\nreal\t%3lR\nuser\t%3lU\nsys%3lS'
time hive -f query2.sql
unset TIMEFORMAT
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With