shell


shell script “syntax error: `done' unexpected.”


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.
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.

Related Links

Error Handling for executing multiple sub shell scripts in parallel
Cron Job evaluating timestamp for the first time
howto append/modify files in docker container from 'docker run … [command]'
Remove characters from specific length
How to use inotifywait to watch for file rename in shell script
Shell script to slice lines and get the first part
how to check if process is running or not every 10mins for one hour using shell
exclude file extension on shell script
Warn User If any value is not Numeric in shell script
Prevent kill from outputting message
How do I extract table name between from and where using unix from a .txt file
How can I use inline variables in a .bat file?
Is pipeline guaranteed to create a subshell in any POSIX shell?
which is the fastest way to print in awk
“free command not found” while running bash script using git bash
Conditional in shell script

Categories

HOME
cygwin
oracle12c
fuelux
gdb
polymer
c99
github-for-windows
zend-framework
spring-data-redis
pdfbox
aws-cli
settings
code-coverage
speech-synthesis
gource
3nf
gruntfile
esoteric-languages
red5
cfml
systemtime
joptionpane
draft-js-plugins
tiki-wiki
bioinformatics
iis-express
tizen-tv
constexpr
custom-controls
database-comparison
clickjacking
sammy.js
keras-layer
hunspell
pop3
cin
plaintext
wmp
linqpad
fwrite
reportservice2010
twilio-click-to-call
corruption
stdmap
context-sensitive-grammar
mouseleave
cpu-cache
android-instrumentation
restore
change-tracking
cubism.js
reporting-services-2012
qtplugin
appscale
swizzling
cassia
bizagi
aurora
cycle2
mobiledoc-kit
lasso
dulwich
xmltype
ejb-2.x
pseudo-class
jama
insight.database
parallel-testing
wxformbuilder
gwt-openlayers
kendo-dataviz
windows-phone-8-sdk
node-blade
octal
font-awesome-4.0.0
mysql-error-2013
twisted.web
android-sdk-2.3
intersect
extreme-programming
onmousemove
box2d-iphone
htdocs
update-statement
tournament
mtu
strtod
fault-tolerance
appliance
commercial-application

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App