Reputation: 311
I am new to linux shell scripting, here is a snippet I want to use:
while IFS='' read -r line || [[ -n "$line" ]]; do
echo ""
echo ""
echo ""
echo "Counting the table : $line"
eval "hive -e 'select count(*) from $line'"
done < "$1"
I name it as count_row.sh. Here is the usage:
$ ./count_row.sh t1.csv > row.txt
t1.csv basically contains some table's name each line.
I got an error below:
But the snippet I borrowed here was marked as accepted solution, presumably it is correctly written. So what am I missing here? Thank you very much.
Upvotes: 0
Views: 694
Reputation: 191844
If you have table names each on their own line, that is a regular text file, not a csv, by the way.
Try not using eval
, though, and instead run the statement inline.
#!/bin/bash
while IFS= read -r line; do
echo "${line}: $(hive -e 'select count(*) from ${line}')"
done < "$1"
If you want to test your script better, I would suggest a for
loop over a hard-coded list of tables.
Upvotes: 1