How to use the command 'brew list' (with examples)

How to use the command 'brew list' (with examples)

The ‘brew list’ command is a useful tool for managing packages and applications on macOS using Homebrew. It allows you to list installed formulae and casks, as well as their associated files and artifacts. This command provides a way to see what packages have been installed and what files are associated with each package.

Use case 1: List all installed formulae and casks

Code:

brew list

Motivation: This use case is useful if you want to see a comprehensive list of all the formulae and casks that have been installed on your system using Homebrew. It gives you an overview of the packages that are currently installed and available for use.

Explanation: The ‘brew list’ command without any additional arguments will list all the installed formulae and casks.

Example output:

ack
bash
cmake
python@3.9
spotify

Use case 2: List files belonging to an installed formula

Code:

brew list formula

Motivation: When you have a specific formula installed and you want to see what files are associated with it, this use case comes in handy. It allows you to get a list of all the files and directories installed by a particular formula.

Explanation: Replace ‘formula’ in the command with the name of the formula you want to list the files for. For example, if you want to list the files for the ‘python@3.9 ’ formula, you would use the command ‘brew list python@3.9 ’.

Example output:

/usr/local/Cellar/python@3.9/3.9.7_1/bin/2to3
/usr/local/Cellar/python@3.9/3.9.7_1/bin/idle3.9
/usr/local/Cellar/python@3.9/3.9.7_1/bin/python3.9
...

Use case 3: List artifacts of a cask

Code:

brew list cask

Motivation: Casks are used to install macOS applications and this use case allows you to see the associated artifacts for a specific cask. It provides information about the files and directories related to a particular cask.

Explanation: Replace ‘cask’ in the command with the name of the cask you want to list the artifacts for. For example, if you want to list the artifacts for the ‘spotify’ cask, you would use the command ‘brew list spotify’.

Example output:

/Applications/Spotify.app/Contents/Info.plist
/Applications/Spotify.app/Contents/MacOS/Spotify
/Applications/Spotify.app/Contents/Resources/Spotify.icns
...

Use case 4: List only formulae

Code:

brew list --formula

Motivation: If you are only interested in seeing the installed formulae and want to exclude the casks from the list, this use case allows you to do that. It provides a filtered output that only includes the formulae.

Explanation: The ‘–formula’ option is used to specify that you only want to list formulae and exclude the casks from the output.

Example output:

ack
bash
cmake
python@3.9

Use case 5: List only casks

Code:

brew list --cask

Motivation: Similarly to the previous use case, if you are only interested in seeing the installed casks and want to exclude the formulae from the list, this use case is useful. It provides a filtered output that only includes the casks.

Explanation: The ‘–cask’ option is used to specify that you only want to list casks and exclude the formulae from the output.

Example output:

spotify

Conclusion:

The ‘brew list’ command is a versatile tool for listing installed formulae and casks, as well as their associated files and artifacts. It allows you to get a comprehensive overview of the packages installed on your system and manage them effectively. With the use cases provided, you can customize the output and focus on either formulae or casks as per your requirements.

Related Posts

How to use the command ppmtompeg (with examples)

How to use the command ppmtompeg (with examples)

ppmtompeg is a command that can be used to encode an MPEG-1 stream.

Read More
How to use the command sshare (with examples)

How to use the command sshare (with examples)

The sshare command is used to list the shares of associations to a cluster in Slurm.

Read More
How to use the command Out-String (with examples)

How to use the command Out-String (with examples)

The Out-String command is used in PowerShell to output input objects as a string.

Read More