0
#!/bin/sh
IFS=$'\n' ARR=(`lvs | grep -v LV | awk '{print $1}'`)

for A in ${ARR[*]}
do
        echo $A
done

for ((i=0;i<${#ARR[*]};i++))
do
        echo $i
done

The result of the above script

home

root

swap

fedora

0

1

2

3

I want the following results

0 home

1 root

2 swap

3 fedora

Charles Duffy
  • 280,126
  • 43
  • 390
  • 441
sangyul lee
  • 103
  • 2
  • 7

1 Answers1

0

I suggest that you concatenate each $A with a separator, and then echo the string at the end if you want it on one line.

Sweet Chilly Philly
  • 3,014
  • 2
  • 27
  • 37