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

  • SEARCH
  • Home
  • 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 9148799
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:22:12+00:00 2026-06-17T11:22:12+00:00

I have this bash script: #!/bin/bash external_output=Oliver’s AirPort Express if ~/.bin/audiodevice | grep $external_output

  • 0

I have this bash script:

#!/bin/bash

external_output="Oliver's AirPort Express"

if ~/.bin/audiodevice | grep "$external_output"
then
  ~/.bin/audiodevice output "Internal Speakers"
  echo "Internal Speakers"
else
  ~/.bin/audiodevice output "$external_output"
  echo "Oliver's AirPort Express"
fi

If the grep is matched, then it of course echoes the match. As I am using it in an if statement, I don’t want this to echo.

How can I use grep in my if statement without having it announce the result to me when I run the script?

  • 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-17T11:22:13+00:00Added an answer on June 17, 2026 at 11:22 am

    You want grep -q "$external_output" to suppress the output. From man grep:

    -q, –quiet, –silent

    Quiet; do not write anything to standard output. Exit immediately with zero status if any match is found, even if an
    error was
    detected (-q is specified by POSIX).

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

Sidebar

Related Questions

i have this script: #!/bin/bash if [[ -z $1 ]] ; then echo Class
On my Centos 6.2 I have this bash script: [le_me]$ cat get.nb #! /bin/bash
I have a bash script that looks like this: #!/bin/sh previousRelease=`git describe --tags --match
For testing purposes I have this shell script #!/bin/bash echo $$ find / >/dev/null
I have a script that looks like this #!/bin/bash function something() { echo hello
I have this code: # Generate bash script $bashScript = #!/bin/bash`n; $bashScript += [string]::Join(`n,
How can I have the right result from this bash script? #!/bin/bash echo $((
I have this bash script here #!/bin/bash find /Users/ -name *.mov -o -name *.flv
I have this script #!/bin/bash function labels2 () { awk ' /[0-9]/{ print substr($3,length($3)-11),
I have this Bash script: #!/bin/bash set -x function doSomething() { callee echo "It

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.