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
  • 257,635
  • 38
  • 339
  • 400
sangyul lee
  • 93
  • 1
  • 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
  • 2,499
  • 2
  • 26
  • 33