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, ....
sed
– ar2015 Apr 02 '15 at 06:28sed
. – Anthon Apr 02 '15 at 06:30set -f;IFS=$'\n';eval "printf '%s\n' "$(./readdata,sh 0 "$in_file)
- but that assumes that the""
double-quoted strings do not contain any characters which might be interpreted within double-quotes. – mikeserv Apr 02 '15 at 06:36" "
around members for this purpose. avoid putting it around members in the original script is much easier. – ar2015 Apr 02 '15 at 06:51...vector=($(...| sed 's/"//;s/"$//'))...
To only affect not-null members do instead:...sed 's/"\(..*\)"/\1/'...
– mikeserv Apr 02 '15 at 07:00