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

Re: newline in command-line argument?



scripsit Kendall Shaw:
> Craig Dickson <crdic@pacbell.net> 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"

You need to do 

echo -e "$A"

for that to work, so if you're doing this interactively (rather than in
a script) the

A="asdf
fdsa"

with 

echo "$A"

will probably work best.

> > or:
> > 
> > A=asdf\
> > fdsa
> 
> Results in: asdffdsa

Using the slash that way does the very opposite of what you want -- it
"hides" the newline so you can type a very long command on multiple
lines to avoid scrolling.

-- 
Thanasis Kinias
Web Developer, Information Technology
Graduate Student, Department of History
Arizona State University
Tempe, Arizona, U.S.A.

Ash nazg durbatulûk, ash nazg gimbatul,
Ash nazg thrakatulûk agh burzum-ishi krimpatul



Reply to: