Loading...
Shell Script

Meta Characters & Backslash

Metacharacters:
Most of the shell special characters are called as metacharacters. They are * / [ ] ‘ ” \ $ ; & ( ) | ^ < > new – line space tab

Backslash:
Backslash is used to quote or nullify the specialty of only one character at a time. We can prevent the echo command or shell from interpreting by placing a backslash(‘\’) in front of a special characters.

$echo Hello ; World
Hello
-bash: World: command not found
$echo Hello \; World
Hello World

In the above example, we expect Hello  ; World but it is Hello. Because of the special character semicolon(;) is present. All the special characters are initialize by shell as variables. So after quoting it with backslash it nullify the specialty of the semicolon(;) and the output will be as expected

Leave a Reply

Your email address will not be published. Required fields are marked *