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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T16:19:03+00:00 2026-06-18T16:19:03+00:00

I tried the following command in bash echo this || echo that && echo

  • 0

I tried the following command in bash

echo this || echo that && echo other

This gives the output

this
other

I didn’t understand that!

My dry run goes this way :

  1. echo this || echo that && echo other implies true || true && true
  2. Since, && has more precedence than ||, the second expression evaluates first
  3. Since, both are true, the || is evaluated which also gives true.
  4. Hence, I conclude the output to be:

that

other

this

Being from a Java background where && has more precedence than ||, I am not able to relate this to bash.

Any inputs would be very helpful!

  • 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-06-18T16:19:05+00:00Added an answer on June 18, 2026 at 4:19 pm

    From man bash

    3.2.3 Lists of Commands

    A list is a sequence of one or more pipelines separated by one of the operators ‘;’, ‘&’, ‘&&’, or ‘||’, and optionally terminated by one of ‘;’, ‘&’, or a newline.

    Of these list operators, ‘&&’ and ‘||’ have equal precedence, followed by ‘;’ and ‘&’, which have equal precedence.

    So, your example

    echo this || echo that && echo other
    

    could be read like

    (this || that) && other
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I tried to run the following command and it says there is nothing to
When I run this command in the bash terminal it works: awk '{ sum
I tried to run the following code, which is inside of a Bash-script. NUMBER=600
The following bash command substitution does not work as I thought. echo $TMUX_$(echo 1)
I tried the following command find ~/dir1 *.m4a | play Directory dir1 has exactly
I tried the following command unsuccessfully sdiff <(ping www.nato.int) <(ping www.reuters.com) Is there any
The following command causes an exception. cv::imwrite(test.jpg, diffImg); I also tried numerous variations on
I tried following the gradle manual with their example like this but copyJars is
I have tried the following on the command line and they work, but when
I'm attempting to execute the following bash command on some images using Ruby: class

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.