7
votes
Accepted
bash pipeline: syntax error near unexpected token 'else'
You have a spurious fi (or else) in the middle of your block.
Shellcheck does point this out as its very first error:
Line 44:
else
^-- SC1009 (info): The mentioned syntax error was in ...
3
votes
bash pipeline: syntax error near unexpected token 'else'
Not an answer, just a suggestion of an enhancement to the code Chris Davies provided - instead of writing essentially the same loop+grep+zip multiple times, even without using a function you could ...
3
votes
bash pipeline: syntax error near unexpected token 'else'
I've had a go at attempting to convert your script to use shell functions and to use nested case statements instead of if statements. I've also fixed numerous quoting errors, but I may have missed a ...
1
vote
bash pipeline: syntax error near unexpected token 'else'
And here's my attempt to tidy up a little. I quoted all (or at least most) variables, I replaced your CAPS names with lower case since it is bad practice to use capitalized names for unexported shell ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
shell-script × 16836bash × 6994
shell × 2441
linux × 1943
scripting × 1188
text-processing × 1125
awk × 1007
sed × 857
files × 501
grep × 483
command-line × 422
ssh × 385
find × 377
variable × 340
ubuntu × 310
zsh × 310
cron × 287
regular-expression × 249
ksh × 234
quoting × 231
pipe × 226
io-redirection × 218
terminal × 206
date × 199
rename × 182