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

Re: newline in command-line argument?



Craig Dickson <crdic@pacbell.net> writes:

> Kendall Shaw wrote:
> 
> > Can I include a newline in an argument on the command line?
> > 
> > For example, this doesn't work:
> > 
> > A='asdf
> > fdsa'
> 
> In what sense doesn't it work? It works for me.
> 
> craig% A='asdf
> fdsa'
> craig% echo "$A"
> asdf
> fdsa
> 
> The quotes in echo "$A" are not optional, by the way, if you want the
> newline displayed correctly.

That's it. Hmm. Why does the newline get eaten without the quotes?

David Jardine <david@jardine.de> writes:

> On Fri, Aug 09, 2002 at 02:43:39PM -0700, Thanasis Kinias wrote:
> > scripsit Kendall Shaw:
> > > Can I include a newline in an argument on the command line?
> > > 
> > > For example, this doesn't work:
> > > 
> > > A='asdf
> > > fdsa'
> > 
> > How about:
> > 
> > A="asdf\nfdsa"

Results in: "asdf\nfdsa"

> or:
> 
> A=asdf\
> fdsa

Results in: asdffdsa

Kendall



Reply to: