Quoting with Backslashes

To start out, let's use echo to get a better idea about how the shell treats special characters. For example,

$ echo Hello world

displays the following message on your screen:

Hello world

Watch what happens if you add the semicolon (;) meta-character in between Hello and world:

$ echo Hello; world
Hello
sh: world: Command not found

The semicolon (;) character tells the shell that it has reached the end of one command and what follows is a new command. This character enables multiple commands on one line. Because world is not a valid command, you get an error message (the error message on your system might be slightly different).

In order to display a meta-character, you need to quote it. When a character is quoted, ...

Get Sams Teach Yourself Shell Programming in 24 Hours, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.