help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] Using single quotes to escape a newline


From: Stephane Chazelas
Subject: Re: [Help-bash] Using single quotes to escape a newline
Date: Wed, 1 Jul 2015 15:31:54 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

2015-07-01 07:21:46 -0700, Michael Convey:
> According to: Newham, Cameron (2005-03-29). Learning the bash Shell: Unix
> Shell Programming (In a Nutshell (O'Reilly)) (Kindle Locations 863-864).
> O'Reilly Media. Kindle Edition.
> 
> "Whether you use a backslash or a single quote, you are telling the shell
> to ignore the special meaning of the RETURN character."
> 
> However, when I try to use single quotes to escape a newline, the newline
> is not escaped, as follows:
> 
> $ echo 'the fox
> > ran down the hill'
> the fox
> ran down the hill
> $
> 
> Has the ability of single quotes to escape a newline changed since this
> book was written?
[...]

Where that book is incorrect is about the backslash case.

In:

echo 'x
y'

The *special meaning of* newline is removed in that the newline
is passed to echo as any other non-special character while in

echo x
y

The newline would be considered as a command delimiter (["echo",
"x"] command followed by ["y"] command).

In

echo x\
y

however, the newline (and backslash) is removed altogether. It's
the same as

echo xy

-- 
Stephane




reply via email to

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