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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:43:22+00:00 2026-06-15T15:43:22+00:00

I have a simple bash script. # Which display is HDMI ? for i

  • 0

I have a simple bash script.

# Which display is HDMI ?
for i in `seq 0 $displayLoopCounter`
do
    name=$(adb shell cat /sys/devices/platform/omapdss/display$i/name)

    if [ "$name"=="hdmi" ] ; then
        echo "$name"
        hdmiDisplay="display$i"
    fi
done

OUTPUT of my scipt:

dvi

hdmi

I’m running the scripts using bash myscript.sh

display0 is dvi

display1 is hdmi

  • 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-15T15:43:23+00:00Added an answer on June 15, 2026 at 3:43 pm

    Your problem lies with the fact that you don’t have spaces around the == in your if line. That makes it a single-argument expression about which the bash manpage states:

    1 argument: The expression is true if and only if the argument is not null.

    If you run the following script (with no spaces around the ==):

    #!/bin/bash
    echo Hello >myfile0
    echo fileData >myfile1
    counter=1
    for i in `seq 0 $counter`
    do
        name=$(cat myfile$i)
        if [ "$name"=="fileData" ]; then
            echo $name
        fi
    done
    rm myfile[01]
    

    you’ll see that the output has both lines, Hello and fileData. Putting the spaces in, you’ll get only fileData because that same manpage states:

    3 arguments: If the second argument is one of the binary conditional operators listed above under CONDITIONAL EXPRESSIONS, the result of the expression is the result of the binary test using the first and third arguments as operands.

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

Sidebar

Related Questions

I have a simple script which is behaving un-expectedly. path='/usr/local/bin/new_script' content='#!/bin/bash\nls' sudo echo -e
I have a simple bash script, called print_code.sh , that takes a file name,
I have a simple test bash script which looks like that: #!/bin/bash cmd=rsync -rv
I have a simple bash script which calls a php script every 10 minutes
I have a very simple script: #!/bin/bash gnuplot << EOF set term postscript portrait
I have a bash script which I'm reading the results from in my program.
I have a bash script that tests whether the sftp connection exists, very simple
I have a script which outputs some data from a postgres database: #!/bin/bash dbname=inventory
Thanks for your help in advance. I'm writing a simple bash script, which just
I which to make a simple little bash script that toggle some files (specifically

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.