15 Special Characters You Need to Know for Bash
If you want to master the Bash shell on Linux, macOS, or another UNIX-like system, special characters (like ~, *, |, and >) are critical. We’ll help you unravel these cryptic Linux command sequences and become a hero of hieroglyphics.
What Are Special Characters?
There are a set of characters the Bash shell treats in two different ways. When you type them at the shell, they act as instructions or commands and tell the shell to perform a certain function. Think of them as single-character commands.
Sometimes, you just want to print a character and don’t need it to act as a magic symbol. There’s a way you can use a character to represent itself rather than its special function.
We’ll show you which characters are “special” or “meta-” characters, as well as how you can use them functionally and literally.
~ Home Directory
The tilde (~) is shorthand for your home directory. It means you don’t have to type the full path to your home directory in commands. Wherever you are in the filesystem, you can use this command to go to your home directory:
cd ~
You can also use this command with relative paths. For example, if you’re somewhere in the file system that’s not under your home folder and want to change to the archive
directory in your work
directory, use the tilde to do it:
cd ~/work/archive