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

Alias “cd” so that it will automatically autocomplete and attempt to move to directory
creating a shell script to automate csv export in mongo db
Devise script command utility with one simple line command
“ps aux” output on the webpage?
How can I write in 2nd column keeping the previous column is empty of a file in shell/awk? [duplicate]
sed command doesn't work in shell script
Why it is taking the same time?
SSH Shell in Canada for SSHTunnel/Socks proxy testing
cat files together with newline in shellscript
How to specify the current directory in Windows Shell?
find and grep command this but not that
shell scripting help
Loop in Gnu make file
confirmed exit using trap
How to run a program with arguments with MONO?
Write shell script in Windows Xp

Categories

HOME
uml
phpword
porting
gridview
prism
eslint
google-spreadsheet
jax-rs
solaris
package
opendj
nuget-package
webix
lanczos
bing-maps
okhttp
32bit-64bit
drop-down-menu
android-securityexception
x-cart
rtf
comsol
heat
symfony-2.8
wolframalpha
delphi-xe5
apache2.4
drive
babel
gulp-watch
dataflow-diagram
easeljs
exploit
tosca
google-api-client
custom-post-type
android-sharedpreferences
pylons
inversion-of-control
sinch
paperjs
mql
deltaspike
playstation-portable
simplecv
hibernate-search
navigator
zoomify
git-rewrite-history
password-protection
diacritics
doc
attributeerror
subclipse
stylecop
snapchat
fwrite
automapper-5
dotnet-httpclient
twilio-click-to-call
tf
podscms
amq
tinkerpop
truezip
sundials
quicktime
vcloud-director-rest-api
grails-plugin
custom-lists
qtplugin
firebase-security
fuzzywuzzy
fink
ascii-art
jbase
vhosts
file-move
computer-architecture
poppler
opserver
page.js
uncompress
zend-currency
theos
git-repo
notorm
kogrid
neos-server
route-provider
dolby-audio-api
wimax
subgraph
usertype
floating-point-exceptions
htdocs
fsevents
automationelement
listactivity
jqote
strsep
instantiationexception
cruisecontrol.rb
facebook-iframe
zend-rest
pos-for-.net

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