This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Variable read error? Multiple spaces


Siddhartha Shivshankar <s_siddhartha <at> yahoo.com> writes:

> 
> Hi. After I try to read the contents of a file containing    
> multiple spaces into a bash variable, only one space is seen    
> 
> in the variable. Output similar to the following 2 space    
> example is seen for 3 spaces as well.  Is this an error? If    
> so, does anyone know a work-around?   

It is an error on your part for not quoting properly.  But this
is not cygwin-specific, so I would advise getting a good
tutorial on shell programming and reading it (the web has
plenty of resources, google is your friend).

> $ export b=`cat i.txt`
> 
> $ echo $b
> Hello world

Try echo "$b" instead.

> 
> $ export b=$(<i.txt)

POSIX states that $() command substitutions that consist solely of
redirections produce unspecified results, and are thus non-portable.

-- 
Eric Blake
volunteer cygwin bash maintainer



--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]