bug-bash
[Top][All Lists]
Advanced

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

Problem using two bash arrays and displaying them at same time.


From: shawn . starr
Subject: Problem using two bash arrays and displaying them at same time.
Date: Fri, 28 Mar 2003 13:53:41 -0500 (EST)

Configuration Information [Automatically generated, do not change]:
Machine: sparc
OS: solaris2.8
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='sparc' 
-DCONF_OSTYPE='solaris2.8' -DCONF_MACHTYPE='sparc-sun-solaris2.8' 
-DCONF_VENDOR='sun' -DSHELL -DHAVE_CONFIG_H   -I.  -I. -I./include -I./lib -g 
-O2
uname output: SunOS myhostname 5.8 Generic_108528-09 sun4u sparc SUNW,UltraAX-i2
Machine Type: sparc-sun-solaris2.8

Bash Version: 2.05a
Patch Level: 0
Release Status: release

Description:
        Creating two arrays, one of them is being corrupted when displaying 
both of them in the same line.
Repeat-By:
#!/bin/bash

declare -a first
declare -a second

CHECK1=`./test.exp | grep dxxx | awk -F"|" '{ printf ("%s %s %s\r\n", 
$1,$2,$8); }'`

x=1
while [ $x -le 3 ]; do
      first[x]="`echo "$CHECK1" | awk -F"\r" '{ print $1 }' | head -$x | tail 
-1`"
      echo "${first[x]}"
      let "x += 1"
done

sleep 5
CHECK2=`./ivrtest.exp | grep dxxx | awk -F"|" '{ printf ("%s %s %s\r\n", 
$1,$2,$8); }'`

x=1
while [ $x -le 3 ]; do
      second[x]="`echo "$CHECK2" | awk -F"\r" '{ print $1 }' | head -$x | tail 
-1`"
      echo "${second[x]}"
      let "x += 1"
done

dummy1=${first[1]}
dummy2=${second[1]}
echo "$dummy1 == $dummy2"

-------
Output in address@hidden:
 1 1 1
 1 2 4
 1 3 45

Output in address@hidden:
 1 1 1
 1 2 7
 1 3 1

Expected output to see:

1 1 1 == 1 1 1

Output currently being seen:

 == 1 1 1

Why is this?






reply via email to

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