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

Shell script [Expected end of line, etc. but found unknown token]
Including date and time in Tex File
script unable to find directories/files when running from qsub cluster script
how to use a shell script to supply a password when the interface asks for it
Efficient way to get your IP address in shell scripts
extract specific folder in shell command using unzip
On Solaris, what is the difference between cut and gcut?
How to match string/dir in a path using bash scripting
KornShell (ksh) SegFault
Is there a command similar to iwevent to monitor eth0 state?
shell-scripting: Use a pipe as an input for tar
Ash (shell provided by busybox) tutorial [closed]
Searching a CSV File Using Grep
How to set the process name of a shell script?
Tell if a user has SUed in a shell script?
Why does this if statement fail in bourne shell?

Categories

HOME
turing-machines
jpa
cheerio
c++11
obfuscation
tivoli
3d-reconstruction
echo
crystal-reports-2013
rcloud
categorical-data
java.util.logging
project-intu
nancy
favicon
dreamweaver
blade
roundup
scatter3d
python-2.6
record
memory-address
autolisp
mailkit
activexobject
xcode7.3
openalpr
opensmpp
chef-solo
hackintosh
watchface
apache-directory
openal
launchctl
lightning
podscms
boo
cpu-cache
branch-prediction
vcloud-director-rest-api
taocp
pure-css
webjars
xcode-server
lrs
google-cloud-console
signalr.client
mongodb-php
model-associations
cfchart
html-to-pdf
halcon
np-spring
atan2
linklabel
grgit
gocql
rubaxa-sortable
mirror
mraid
zend-currency
java-security
openbabel
delayed-execution
at-job
uncaught-typeerror
crowd
xml-namespaces
lambda-architecture
matrix-inverse
jjaql
clickbank
multitasking
c++builder-xe5
neos-server
stacky
fb.ui
resource-management
device-width
paginator
oracle-enterprise-linux
relative
screen-size
drawtobitmap
cloudfiles
objective-j
non-clustered-index
web-application-project
cldc
windows-identity
scrubyt

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App