Bash scripting skills in Mac OS terminal
Here is a list of some common Bash commands that are available on macOS:
Command | Description |
---|---|
alias |
Defines an alias for a command |
bg |
Resumes a suspended job in the background |
cd |
Changes the current directory |
chmod |
Changes the permissions of a file |
clear |
Clears the terminal screen |
cp |
Copies a file |
echo |
Prints a message to the console |
fg |
Brings a background job to the foreground |
grep |
Searches for a pattern in a file or output |
kill |
Sends a signal to a process to terminate it |
less |
Displays the contents of a file one page at a time |
ls |
Lists the files in a directory |
man |
Displays the manual page for a command |
mkdir |
Creates a new directory |
mv |
Moves or renames a file |
ps |
Lists the processes running on the system |
pwd |
Displays the current working directory |
rm |
Deletes a file |
sed |
Edits a file or output in a scriptable way |
sort |
Sorts the lines of a file or output |
tail |
Displays the last lines of a file |
tee |
Sends output to a file and the console |
top |
Displays the processes using the most resources |
wc |
Counts the lines, words, and characters in a file |
while |
Executes a command repeatedly while a condition is true |
awk |
Processes text files and performs operations on them |
cat |
Concatenates files and displays them on the console |
cut |
Extracts specified fields from a file |
date |
Displays the current date and time |
diff |
Compares the contents of two files |
echo |
Prints a message to the console |
The Bash shell supports a wide range of commands, and the specific set of commands available to you will depend on the version of Bash and the installed software on your system. Some Bash commands may not be available on macOS due to differences in the underlying operating system and the software that is installed.
Here are a few examples of Bash commands that may not be available on macOS:
yum
: This command is used to manage packages on systems that use the Yellowdog Updater, Modified (YUM) package manager, such as CentOS and Fedora. It is not available on macOS, which uses the package manager Homebrew.apt-get
: This command is used to manage packages on systems that use the Advanced Packaging Tool (APT) package manager, such as Debian and Ubuntu. It is not available on macOS, which uses the package manager Homebrew.systemctl
: This command is used to manage system services on systems that use the Systemd init system, such as CentOS, Fedora, and Red Hat Enterprise Linux. It is not available on macOS, which uses the launchd init system.