Skip to main content
Tweeted twitter.com/#!/StackUnix/status/584765620367024128
edited tags
Link
Gilles 'SO- stop being evil'
  • 865.4k
  • 205
  • 1.8k
  • 2.3k
Source Link
ar2015
  • 212
  • 3
  • 9

Bash : Native way to get rid of quotation around each array member

I read an array from another script. This array needs to put " " around all array members since some members are empty.

in_file=./data
vector=($(./readdata.sh 0 $in_file))
for index in ${!vector[@]}
do
    echo ${vector[index]}
done

The problem is that I have quotations around each output line and I want to get rid of them.

"red"
"blue"
"green"
""
"white"
"black"

must change to:

red
blue
green

white
black

I look for a method which does not use awk, tr, sed or any other pipeline based way. I just want to solve with using native ways such as using parenthesis, different punctuations, ....