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 7159217
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:11:39+00:00 2026-05-28T13:11:39+00:00

Simple Bash +1 please Hey there. I know I’m missing something simple in this

  • 0

Simple Bash +1 please

Hey there. I know I’m missing something simple in this script. But what is it? an exit? fi?
When I use Name -online i get the echo “Bool Changed offline2” from the very last section. Online code shouldnt clash with Offline. Help, I’ve been at this for hours.

if [ "$1" == "-online" ]; then
        if [ "$Check" == "com.company.package1" ]; then
            plutil -key settingsOfflineMode -value 0 -type bool /the/dir/ect/ory/com.company.package1 &> /dev/null
            echo "Bool Changed online1"
            exit
        fi
    else
        if [ "$Check" == "com.company.package2" ]; then
            plutil -key settingsOfflineMode -value 0 -type bool /the/dir/ect/ory/com.company.package2 &> /dev/null  ////EDITED TO com.company.package2
            echo "Bool Changed online2"
            exit        
        fi
    fi


if [ "$1" == "-offline" ]; then
        if [ "$Check" == "com.company.package1" ]; then
            plutil -key settingsOfflineMode -value 0 -type bool /the/dir/ect/ory/com.company.package1 &> /dev/null
            echo "Bool Changed offline1"
            exit
        fi
    else
        if [ "$Check" == "com.company.package2" ]; then
            plutil -key settingsOfflineMode -value 0 -type bool /the/dir/ect/ory/com.company.package2 &> /dev/null  //EDITED TO com.company.package2
            echo "Bool Changed offline2"
            exit        
        fi
    fi
  • 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-28T13:11:40+00:00Added an answer on May 28, 2026 at 1:11 pm

    Assuming that $Check is set to “com.company.package2” (which, unfortunately you don’t show), this is what your script is doing:

    • The first if is true because the command argument is “-online”.
    • The second if is false (“package2” != “package1”)
    • The first else is skipped since the first if was true
    • The “-offline” if is false, so its else path is taken
    • The final if is true (“package2” != “package2”) so the message is echoed

    else if is not the same as elif

    Because you close the inner if statements with fi, the else is evaluated for the outer if statements.

    You probably want:

    #!/bin/bash
    
    Check=com.company.package2
    
    if [[ $1 == "-online" ]]; then
            if [[ $Check == "com.company.package1" ]]; then
                plutil -key settingsOfflineMode -value 0 -type bool /the/dir/ect/ory/com.company.package1 &> /dev/null
                echo "Bool Changed online1"
                exit
            elif [[ $Check == "com.company.package2" ]]; then
                plutil -key settingsOfflineMode -value 0 -type bool /the/dir/ect/ory/com.company.package2 &> /dev/null  ////EDITED TO com.company.package2
                echo "Bool Changed online2"
                exit
            fi
    elif [[ $1 == "-offline" ]]; then
            if [[ $Check == "com.company.package1" ]]; then
                plutil -key settingsOfflineMode -value 0 -type bool /the/dir/ect/ory/com.company.package1 &> /dev/null
                echo "Bool Changed offline1"
                exit
            elif [[ $Check == "com.company.package2" ]]; then
                plutil -key settingsOfflineMode -value 0 -type bool /the/dir/ect/ory/com.company.package2 &> /dev/null  //EDITED TO com.company.package2
                echo "Bool Changed offline2"
                exit
            fi
    fi
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a very simple bash script I wrote: #!/bin/bash ITEM_LIST=items.txt LOG_FILE=log.log TOTAL_ITEMS=$(wc -l
I have a simple bash script, called print_code.sh , that takes a file name,
I'm running a pretty simple bash script in ubuntu but have come up with
Is there a simple Windows equivalent for this bash command: head -c 500 /dev/urandom
I have written a very simple bash script to help me migrate from dev
I'm trying to create a simple BaSH-like grammar on ANTLRv3 but haven't been able
I want to create a simple bash script to launch a Java program on
I have a simple test bash script which looks like that: #!/bin/bash cmd=rsync -rv
I am trying to run this dreadfully simple command in Bash java -cp nasa-top-secret.jar
I am writing a simple unix shell script: #!/bin/bash # abort the script if

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.