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



casioculture@xxxxxxxxx writes:

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.

#v+
for varname in FOO BAR BAZ QUX; do
printf "Enter $varname: "
read $varname
done
printf '%s,%s,%s,%s\n' "$FOO" "$BAR" "$BAZ" "$QUX"
#v-

?

--
Best regards, _ _
.o. | Liege of Serenly Enlightened Majesty of o' \,=./ `o
..o | Computer Science, Michal "mina86" Nazarewicz (o o)
ooo +--<mina86*tlen.pl>--<jid:mina86*jabber.org>--ooO--(_)--Ooo--
.



Relevant Pages

  • Re: Days until Dec 1
    ... > echo You have $diffdate days until the big event ... brute force fix is: ... The sed command strips leading zeros, ... tries to treat the two variables as commands ($(varname) ...
    (comp.os.linux)
  • Re: Substring Each Line in a File
    ... know how to echo a substring of each line (I will then redirect each ... This pulls off the 13 characters I am looking for, ... Note that %varname% is the value of varname at the logical line's PARSE ...
    (microsoft.public.win2000.cmdprompt.admin)
  • Re: Substring Each Line in a File
    ... know how to echo a substring of each line (I will then redirect each ... It produces the 13 characters starting at the SECOND ... SETLOCAL ENABLEDELAYEDEXPANSION ... Note that %varname% is the value of varname at the logical line's PARSE ...
    (microsoft.public.win2000.cmdprompt.admin)
  • 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 ...
    (comp.unix.shell)