[Top][All Lists]

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

Re: For loop prints two $values instead of one

From: Greg Wooledge
Subject: Re: For loop prints two $values instead of one
Date: Tue, 7 Jan 2014 08:21:41 -0500
User-agent: Mutt/

On Tue, Jan 07, 2014 at 12:45:42AM +0200, DanielB wrote:
> declare -a array=( 'sf052' 'to060' 'pw' 'qb099' 'pw22' 'wp039' 'wx12'
> 'wx11' )for subD in "address@hidden"; do
>     echo $subDdone
> output:
> sf052
> to060
> pw
> qb099 pw22
> wp039 wx12
> wx11

I can only guess that your terminal is in some weird state, and/or your
IFS variable has been set to something bizarre.  The hypothesis about
your terminal being in a weird state is somewhat strengthened by the
mangling that was done in your email.

If you properly quote "$subD" it will avoid any issues with IFS:

for subD in "address@hidden"; do
  echo "$subD"

Apart from the mangled formatting and the missing quotes, there's nothing
wrong with your code.

As for the terminal, you can try running the "reset" command, but in the
most spectacular cases, it's often necessary to close the terminal window
and open a new one (assuming a terminal emulator), or power the terminal
off and back on (assuming a physical ASCII terminal).

reply via email to

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