Skip to main content
deleted 5 characters in body
Source Link
Matt Komarnicki
  • 1.7k
  • 6
  • 24
  • 40

Using bash, I want to check if Command Line Tools are installed.

Currently they are and when I will type xcode-select --install I get:

xcode-select: error: command line tools are already installed, use "Software Update" to install updates It appears Homebrew is already installed. If your intent is to reinstall you should do... blah blah blah

Basically my problem is that I have several methods to check it in bash (using if / fi) but I don't know which solution is the best one.

  1. I can do xcode-select -p and that returns the path /Library/Developer/CommandLineTools but then how I should build the if statement? I don't know what will be presented when CLT are not installed.

  2. I can do xcode-select --version. Should I then grep for a phrase version since I get

xcode-select version 2343.

  1. I can do which xcode-select but again, in all cases I'm not sure how the if should look like. I also think that grep is not the best way, since in the future the output may be different in future version of OSX.

To sum up I would like something like

#!/bin/bash
if [ no idea ]; then
    #installed, nothing to do...
else
    xcode-select --install
fi

Thanks for any suggestions.

Using bash, I want to check if Command Line Tools are installed.

Currently they are and when I will type xcode-select --install I get:

xcode-select: error: command line tools are already installed, use "Software Update" to install updates It appears Homebrew is already installed. If your intent is to reinstall you should do... blah blah blah

Basically my problem is that I have several methods to check it in bash (using if / fi) but I don't know which solution is the best one.

  1. I can do xcode-select -p and that returns the path /Library/Developer/CommandLineTools but then how I should build the if statement? I don't know what will be presented when CLT are not installed.

  2. I can do xcode-select --version. Should I then grep for a phrase version since I get

xcode-select version 2343.

  1. I can do which xcode-select but again, in all cases I'm not sure how the if should look like. I also think that grep is not the best way, since in the future the output may be different in future version of OSX.

To sum up I would like something like

#!/bin/bash
if [ no idea ]; then
    #installed, nothing to do...
else
    xcode-select --install
fi

Thanks for any suggestions.

Using bash, I want to check if Command Line Tools are installed.

Currently they are and when I type xcode-select --install I get:

xcode-select: error: command line tools are already installed, use "Software Update" to install updates It appears Homebrew is already installed. If your intent is to reinstall you should do... blah blah blah

Basically my problem is that I have several methods to check in bash (using if / fi) but I don't know which solution is the best one.

  1. I can do xcode-select -p and that returns the path /Library/Developer/CommandLineTools but then how I should build the if statement? I don't know what will be presented when CLT are not installed.

  2. I can do xcode-select --version. Should I then grep for a phrase version since I get

xcode-select version 2343.

  1. I can do which xcode-select but again, in all cases I'm not sure how the if should look like. I also think that grep is not the best way, since in the future the output may be different in future version of OSX.

To sum up I would like something like

#!/bin/bash
if [ no idea ]; then
    #installed, nothing to do...
else
    xcode-select --install
fi

Thanks for any suggestions.

Tweeted twitter.com/askdifferent/status/680821697998655490
added 6 characters in body
Source Link
Matt Komarnicki
  • 1.7k
  • 6
  • 24
  • 40

Using bash, I want to check if Command Line Tools are installed.

Currently they are and when I will type xcode-select --install I get:

xcode-select: error: command line tools are already installed, use "Software Update" to install updates It appears Homebrew is already installed. If your intent is to reinstall you should do... blah blah blah

Basically my problem is that I have several methods to check it in bash (using if / fi) but I don't know which solution is the best one.

  1. I can do xcode-select -p and that returns the path /Library/Developer/CommandLineTools but then how I should build the if statement? I don't know what will be presented when CLT are not installed.

  2. I can do xcode-select --version. Should I then grep for a phrase version since I get

xcode-select version 2343.

  1. I can do which xcode-select but again, in all cases I'm not sure how the if should look like. I also think that grep is not the best way, since in the future the output may be different in future version of OSX.

To sum up I would like something like

#!/bin/bash
if [ no idea ]; then
    #installed, nothing to do...
else
    xcode-select --install
fi

Thanks for any suggestions.

Using bash, I want to check if Command Line Tools are installed.

Currently they are and when I will type xcode-select --install I get:

xcode-select: error: command line tools are already installed, use "Software Update" to install updates It appears Homebrew is already installed. If your intent is to reinstall you should do... blah blah blah

Basically my problem is that I have several methods to check it in bash (using if / fi) but I don't know solution is the best one.

  1. I can do xcode-select -p and that returns the path /Library/Developer/CommandLineTools but then how I should build the if statement? I don't know what will be presented when CLT are not installed.

  2. I can do xcode-select --version. Should I then grep for a phrase version since I get

xcode-select version 2343.

  1. I can do which xcode-select but again, in all cases I'm not sure how the if should look like. I also think that grep is not the best way, since in the future the output may be different in future version of OSX.

To sum up I would like something like

#!/bin/bash
if [ no idea ]; then
    #installed, nothing to do...
else
    xcode-select --install
fi

Thanks for any suggestions.

Using bash, I want to check if Command Line Tools are installed.

Currently they are and when I will type xcode-select --install I get:

xcode-select: error: command line tools are already installed, use "Software Update" to install updates It appears Homebrew is already installed. If your intent is to reinstall you should do... blah blah blah

Basically my problem is that I have several methods to check it in bash (using if / fi) but I don't know which solution is the best one.

  1. I can do xcode-select -p and that returns the path /Library/Developer/CommandLineTools but then how I should build the if statement? I don't know what will be presented when CLT are not installed.

  2. I can do xcode-select --version. Should I then grep for a phrase version since I get

xcode-select version 2343.

  1. I can do which xcode-select but again, in all cases I'm not sure how the if should look like. I also think that grep is not the best way, since in the future the output may be different in future version of OSX.

To sum up I would like something like

#!/bin/bash
if [ no idea ]; then
    #installed, nothing to do...
else
    xcode-select --install
fi

Thanks for any suggestions.

Source Link
Matt Komarnicki
  • 1.7k
  • 6
  • 24
  • 40

Best way to check in bash if Command Line Tools are installed?

Using bash, I want to check if Command Line Tools are installed.

Currently they are and when I will type xcode-select --install I get:

xcode-select: error: command line tools are already installed, use "Software Update" to install updates It appears Homebrew is already installed. If your intent is to reinstall you should do... blah blah blah

Basically my problem is that I have several methods to check it in bash (using if / fi) but I don't know solution is the best one.

  1. I can do xcode-select -p and that returns the path /Library/Developer/CommandLineTools but then how I should build the if statement? I don't know what will be presented when CLT are not installed.

  2. I can do xcode-select --version. Should I then grep for a phrase version since I get

xcode-select version 2343.

  1. I can do which xcode-select but again, in all cases I'm not sure how the if should look like. I also think that grep is not the best way, since in the future the output may be different in future version of OSX.

To sum up I would like something like

#!/bin/bash
if [ no idea ]; then
    #installed, nothing to do...
else
    xcode-select --install
fi

Thanks for any suggestions.