delorie.com/archives/browse.cgi | search |
X-Spam-Check-By: | sourceware.org |
To: | cygwin AT cygwin DOT com |
From: | Eric Blake <ebb9 AT byu DOT net> |
Subject: | Re: Variable read error? Multiple spaces |
Date: | Thu, 27 Apr 2006 23:31:56 +0000 (UTC) |
Lines: | 32 |
Message-ID: | <loom.20060428T012435-615@post.gmane.org> |
References: | <20060427230838 DOT 70271 DOT qmail AT web38913 DOT mail DOT mud DOT yahoo DOT com> |
Mime-Version: | 1.0 |
User-Agent: | Loom/3.14 (http://gmane.org/) |
X-IsSubscribed: | yes |
Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
List-Archive: | <http://sourceware.org/ml/cygwin/> |
List-Post: | <mailto:cygwin AT cygwin DOT com> |
List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs> |
Sender: | cygwin-owner AT cygwin DOT com |
Mail-Followup-To: | cygwin AT cygwin DOT com |
Delivered-To: | mailing list cygwin AT cygwin DOT com |
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/
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |