help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why no closing single quote is needed when a single quote is escaped


From: Chris F.A. Johnson
Subject: Re: Why no closing single quote is needed when a single quote is escaped?
Date: Thu, 31 Dec 2020 18:48:09 -0500 (EST)
User-agent: Alpine 2.22 (DEB 394 2020-01-19)

On Thu, 31 Dec 2020, Peng Yu wrote:

x='\'
The difference between single quoting and double quoting is fully
explained in the bash manual page, under the section "QUOTING".

The man page says the following. But it doesn't say why a closing
single quote is not need to pair with the first quote. Why \' makes
the closing single quote unnecessary.

The closing single quote IS necessary. That's what the second single quote is.

When inside single quotes, the backslash is not special; it is just a
literal backslash ... which is what the following sentence that you
quoted says:

      Enclosing characters in single quotes preserves the literal
value of each character within the  quotes.

--
   Chris F.A. Johnson                         <http://cfajohnson.com/>
   =========================== Author: ===============================
   Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
   Pro Bash Programming: Scripting the GNU/Linux shell (2009, Apress)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]