help-bash
[Top][All Lists]
Advanced

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

[Help-bash] Printing from Array


From: Richard Taubo
Subject: [Help-bash] Printing from Array
Date: Thu, 21 May 2015 18:52:08 +0200

Hei!

Creating a simple array, I am just wondering why the second printf line
does not print any results from the array at all.
I was assuming it would print the "two" and "three" lines in the array.

Thanks for feedback!

#!/bin/bash
MyData="One,two,three"
declare -i q
OIFS=$IFS
IFS=$','
for myColumn in $MyData; do
        MyArray[q++]="${myColumn#*}"
        printf "%s\n" "$q: ${MyArray[q-1]}"
        printf "%s\n" "$q: ${MyArray[q]}"
done
IFS=$OIFS

Best regards,
Richard Taubo



reply via email to

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