1

i try to run that bash code below to get the value in list and store it in variable then get basename and concatenate with it "lv-" :

lv_LST=("/usr/sap" "/sapmnt")
lv_size_as_bash=("4" "3")
((L=1))

for n in $(seq 0 $L)
do
    lv_mount = ${lv_LST[$n]};
    lv_size = ${lv_size_as_bash[$n]};
    lvname1=$(sudo basename $lv_mount);
    lvname2='lv-';
    lvname=$lvname2-$lvname1;

but i get that error:

lv_mount: command not found

failed to run commands: exit status 127
Cyrus
  • 84,225
  • 14
  • 89
  • 153
Reham Adel
  • 43
  • 5
  • Don't use `seq`. If you are using `bash`, you can use a C-style `for` loop (`for ((n=0; n<= $L; n++)))`. If you have to assume POSIX compatibility, you may not be able to assume `seq` is available and you'll need to use a `while` loop anyway. – chepner Feb 06 '22 at 17:55

1 Answers1

0

You have extra spaces

Change

lv_mount = ${lv_LST[$n]};
lv_size = ${lv_size_as_bash[$n]};

To

lv_mount=${lv_LST[$n]};
lv_size=${lv_size_as_bash[$n]};
Tolis Gerodimos
  • 3,782
  • 2
  • 7
  • 14