Skip to main content
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 ...
Chris Davies's user avatar
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 ...
Ed Morton's user avatar
  • 36k
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 ...
cas's user avatar
  • 85.1k
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 ...
terdon's user avatar
  • 253k

Only top scored, non community-wiki answers of a minimum length are eligible