bash guide

Is there a command guide available for the shell environment accessed by the Terminal application?


MacBook Pro (2017 – 2020)

Posted on Dec 18, 2023 10:09 AM

Reply
Question marked as Top-ranking reply

Posted on Dec 18, 2023 1:00 PM

Apple uses an ancient version of Bash 3.2.57 iniitially released in 2006, and due to GNU's GPL3 licensing, Apple will not install a more recent version of Bash (e.g. 5.2) that is installed on most Linux systems. Instead, Apple is committed to providing the Zsh shell which has an MIT license. Learning the Zsh shell would be more strategic for you in future releases of macOS.


Here is a direct link to a PDF Bash 3.2 Reference Manual from Sept 2006. Almost all of the Bash related articles in a Google search are by those running later versions of Bash on Linux and some of that syntax is not implemented in Bash on macOS.


Apple provides the following:


Terminal User Guide for Mac - Apple Support


If you launch the Terminal, you can produce a PDF fromf the Bash 3.2.57 man page. You can copy and paste this in the Terminal followed by a return:


/usr/bin/mandoc -Tpdf -mandoc $(man -w bash) > ~/Desktop/bash3_2_57.pdf


You could follow that with:

open ~/Desktop/bash3_2_57.pdf


or to just quickly open the man page in the Terminal:

man bash


for Zsh man pages, see (not a typo):

man zshall






4 replies
Question marked as Top-ranking reply

Dec 18, 2023 1:00 PM in response to BleedGreen

Apple uses an ancient version of Bash 3.2.57 iniitially released in 2006, and due to GNU's GPL3 licensing, Apple will not install a more recent version of Bash (e.g. 5.2) that is installed on most Linux systems. Instead, Apple is committed to providing the Zsh shell which has an MIT license. Learning the Zsh shell would be more strategic for you in future releases of macOS.


Here is a direct link to a PDF Bash 3.2 Reference Manual from Sept 2006. Almost all of the Bash related articles in a Google search are by those running later versions of Bash on Linux and some of that syntax is not implemented in Bash on macOS.


Apple provides the following:


Terminal User Guide for Mac - Apple Support


If you launch the Terminal, you can produce a PDF fromf the Bash 3.2.57 man page. You can copy and paste this in the Terminal followed by a return:


/usr/bin/mandoc -Tpdf -mandoc $(man -w bash) > ~/Desktop/bash3_2_57.pdf


You could follow that with:

open ~/Desktop/bash3_2_57.pdf


or to just quickly open the man page in the Terminal:

man bash


for Zsh man pages, see (not a typo):

man zshall






Dec 18, 2023 1:32 PM in response to BleedGreen

For a quick overview of bash commands and syntax: https://devhints.io/bash


bash reference card: https://www.cheat-sheets.org/saved-copy/bash_ref.pdf


For a quick overview of zsh commands and syntax: https://devhints.io/zsh


zsh reference card: https://www.bash2zsh.com/zsh_refcard/refcard.pdf


I’d suggest spending more time with zsh than with bash, if macOS is your platform. This as Apple is migrating folks from bash to zsh, and as the installed version of bash is very old.


Use zsh as the default shell on your Mac - Apple Support


Apple has an (old) primer focusing on bash shell scripting available, as well: Introduction


For those with some familiarity with bash now looking at zsh: https://scriptingosx.com/2019/06/moving-to-zsh/

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

bash guide

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.