Re: From a bash array to a csv file line?



casioculture@xxxxxxxxx wrote:

I want to put all my variables in an array and then have bash "read"
the input from the user (me) at runtime for each and then "echo" their
values with the date to a csv file so that all would be comma-separated
on the same line.

Is this possible? Any ideas?


Is this what you mean:

names=( abc def ghi )
end=${#names[@]}
date=`date`

i=0
while (( i < end ))
do
printf "Enter %s: " "${names[$i]}"
read values[$i]
i=$(( $i + 1 ))
done

i=0
printf "%s" "$date"
while (( i < end ))
do
printf ",%s,%s" "${names[$i]}" "${values[$i]}"
i=$(( $i + 1 ))
done
printf "\n"

Regards,

Ed.
.



Relevant Pages

  • Re: From a bash array to a csv file line?
    ... values with the date to a csv file so that all would be comma-separated ... those 3 readings? ...
    (comp.unix.shell)
  • Re: From a bash array to a csv file line?
    ... the input from the user at runtime for each and then "echo" their ... values with the date to a csv file so that all would be comma-separated ... for varname in FOO BAR BAZ QUX; ... printf "Enter $varname: " ...
    (comp.unix.shell)
  • Parsing CSV vertically and horizontally
    ... The data file is normal CSV file. ... first we read config file for data colum names: ... echo Read %COUNT% columns. ...
    (microsoft.public.win2000.cmdprompt.admin)
  • Re: [PHP] CSV Files
    ... I need to take a record in MySQL and have my user get it as a CSV File. ... After I right out the column headers do I have to put a '/n' to have it ... echo $map_BORROWER_DOB; ...
    (php.general)
  • Re: HELP! Scripting newbie question.
    ... printf "File: $file\n" ... There is nothing in your script to do the expand of the $1. ... insert a test by doing an echo $list or echo $1 in your srcipt to ...
    (comp.unix.solaris)