|
Home > Archive > Unix Shell > February 2007 > quoting in a for loop
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
quoting in a for loop
|
|
|
| Hi,
I'm trying to automatically export tables from an M$ Access database to
comma-delimited files using mdbtools commands. This requires sending the
output from mdb-tables to mdb-export. The first command:
mdb-tables -1 fileA.mdb
returns the names of the tables one per line (-1 option), but they may
contain spaces, so they need to be quoted. Ignoring that, I guess one
could do:
$TABLES=$(mdb-table -1 fileA.mdb)
for table in $TABLES; do
mdb-export "$table" > "$table".csv
done
However, I don't know how to dissect $TABLES in this case. It might help
that mdb-tables has an option (-d) which allows each table to be separated
by a given string (e.g. ","). Perhaps using that instead of -1 may make
the task easier, but I'm not finding how exactly! Thanks for any
suggestions you may have.
--
Seb
| |
| Bill Marcum 2007-02-20, 7:18 am |
| On Tue, 20 Feb 2007 06:48:49 GMT, Seb
<spluque@gmail.com> wrote:
>
> Hi,
>
> I'm trying to automatically export tables from an M$ Access database to
> comma-delimited files using mdbtools commands. This requires sending the
> output from mdb-tables to mdb-export. The first command:
> mdb-tables -1 fileA.mdb
> returns the names of the tables one per line (-1 option), but they may
> contain spaces, so they need to be quoted. Ignoring that, I guess one
> could do:
> $TABLES=$(mdb-table -1 fileA.mdb)
> for table in $TABLES; do
> mdb-export "$table" > "$table".csv
> done
>
> However, I don't know how to dissect $TABLES in this case. It might help
> that mdb-tables has an option (-d) which allows each table to be separated
> by a given string (e.g. ","). Perhaps using that instead of -1 may make
> the task easier, but I'm not finding how exactly! Thanks for any
> suggestions you may have.
>
This seems like a job for a pipe and a while read loop, not a for loop.
--
Reading computer manuals without the hardware is as frustrating as reading
sex manuals without the software.
-- Arthur C Clarke
| |
| Michael Tosch 2007-02-20, 7:18 am |
| Bill Marcum wrote:
> On Tue, 20 Feb 2007 06:48:49 GMT, Seb
> <spluque@gmail.com> wrote:
> This seems like a job for a pipe and a while read loop, not a for loop.
>
And this is
mdb-table -1 fileA.mdb |
while read table
do
mdb-export "$table" > "$table".csv < /dev/null
done
--
Michael Tosch @ hp : com
| |
|
| On Tue, 20 Feb 2007 09:14:02 +0100,
Michael Tosch <eedmit@NO.eed.SPAM.ericsson.PLS.se> wrote:
[...]
> mdb-table -1 fileA.mdb |
> while read table
> do
> mdb-export "$table" > "$table".csv < /dev/null
> done
Thanks, modifying it slightly to correct errors I made describing the
tools:
mdb-tables -1 fileA.mdb |
while read table; do
mdb-export fileA.mdb "$table" > "$table".csv
done
Cheers,
--
Seb
|
|
|
|
|