Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1113787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:54:30+00:00 2026-05-17T02:54:30+00:00

I have bash script that I use regularly in my job to automate a

  • 0

I have bash script that I use regularly in my job to automate a large job. I was making some changes today, but everything seemed fine. The script itself is about 1700 lines long. The first part of the script is all good and runs through all the user input and logic just fine. It then proceeds into the core of the script and stops working at exactly line 875 (tested the script with bash -x to find the break point). However, it breaks with the following error:

script.sh: line 1341: syntax error near unexpected token `;;'
script.sh: line 1341: `                    ;;'

Line 1341 is in the middle of a case statement. The following code is the beginning of that block of code where it is breaking:

if [[ $VAR1 = "TRUE"  && $VAR2 = "VAL2" ]]; then
VERSION=`XXXXXXXXXXXXXXXX`
## Set variables based on location $VAR3
case $VAR3 in
    STR1 )
        case $VERSION in
            STR2 )
                VAR4 = "STR5"
                VAR5 = "STR6"
                VAR6 = "STR7"
                VAR7 = "STR8"
Line 1341 --->  ;;
            STR3 )
                VAR4="STR9"
                VAR5="STR10"
                VAR6="STR11"
                VAR7="STR12"
                ;;
            STR4 )
                VAR4="STR13"
                VAR5="STR14"
                VAR6="STR15"
                VAR7="STR16"
                ;;
        esac
        VAR8="STR17"
        VAR9="STR18"
        VAR10=1
        VAR11="STR19"
        ;;

Because of the sensitive nature of what I do, I obviously had to remove quite a bit of information. I know this may make things more difficult to help me with. However, all VAR##=”STR##” are standard variable declarations with string values, nothing special (no variable substitution, etc). All the variables are used later in the script. The code for VERSION returns a string value, which is used in the nested case.

The script was working fine up until my changes today, but I really didn’t touch this section, with the exception of tweaking some of the STR values. I tried setting $VAR3 and $VERSION variables in quotes “”, as well as the STR values used as the cases. I tried taking out this block entirely, only to have it fail on the next block (STR1 has a different value thus change the variable declarations). I have it output to the console what it is doing as well as checks for errors after most functions. There is nothing out of the ordinary on the console and nothing in the error log.

Any help would be appreciated, and I know I’m asking a lot.

By the way here is the code around line 875 where the script stops running (no errors generated based on the code here). Again, with bash -x I could see the VAR2 variable get set, but the script breaks before the next for loop starts.

## Create file ##
echo 'Creating files . . . '
j=0
p=1111
if [ $VAR1 = "TRUE" ]
    then 
        VAR2=1
else 
    VAR2=2
fi
for i in `seq 1 $HOWMANY`; do    <----Line 875
echo -n "Creating file . . . "
echo "XXXXXXXXXXX

Thanks again.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T02:54:30+00:00Added an answer on May 17, 2026 at 2:54 am

    The problem is likely somewhere between line 875 (or a bit earlier) and line 1341. It maybe a misplaced quote or something less subtle. It will be essentially impossible for us to debug without all the original material between those lines.

    Suggestion 1: run with ‘bash -n -v’ and see whether that gives you any insight into the problem.

    Suggestion 2: split the script into smaller pieces that are more easily managed – and that can be separately debugged. The biggest scripts I have (out of 400 in my bin directory) are from the autoconf suite – they weigh in at just under 1100 lines; the next biggest is mine, and the 750 line script is too d..n big. The next biggest scripts are between 600 and 700 lines of Perl (including Perl documentation).


    Having said ‘missing quote’, I see that your fragment close to line 875 has:

    echo -n "Creating file . . . "
    echo "XXXXXXXXXXX
    

    with a missing close double quote from the second echo.


    You also mentioned making changes, albeit not close to the point where the script breaks. Since you have the code under version control (you wouldn’t dream of playing with a 1700 line script without backups, would you?), you should look at the actual changes again.

    Or even back up to the previous working version, and make the changes again, one at a time, carefully, until you see why you broke something.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a bash shell script that loops through all child directories (but not
I have a bash script that I mostly use in interactive mode. However, sometimes
I have a bash script that depends on a group of folders existing, but
I have a bash script that does some parallel processing in a loop. I
I have a bash script that creates a Subversion patch file for the current
I have a bash script that runs a simulation program written in Fortran 90,
I have this line in a useful Bash script that I haven't managed to
I have a portion of a bash script that is getting a filename without
I have a complex command that I'd like to make a shell/bash script of.
I have a bash script to upload some files to my webserver. The problem

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.