The command I'm trying to run:
mdb-tables davidoff.mdb | xargs -I {} mdb-export davidoff.mdb {} > {}.csv
mdb-export takes two arguments, I'm trying to pipe the second one. And then I want each one to be written to a file.
This won't work. Even when I remove the > {}.csv
there is still an error:
Error: Table {} does not exist in this database.
Shell is zsh
example output from first part:
% mdb-tables davidoff.mdb
anatomypiclink bugs bugseverity bugtype classifications Diseases docaccess docaccesstype docassignments docclassifications docdetails docnotes docpicturelink docqa docs doctype keypicturelink keywords links logons mediatype navdoclinks navimagelinks navstructures organs Paste Errors pictureclassifications pictures picturetype qub3_queries_que qub3_relations_rel qub3_settings_set quotes references sequencelinks sequences subDocType videos dictionarytable doclinks docstatus media docs_ExportErrors
As a test case, I was able to make this work:
printf "1\n2\n3\n" | xargs -I touch {}
Why is it that I cannot use replstr as a second argument?
xargs --verbose
will show the command that's going to be executed after substitution. Can you check that and see how it differs from what you expect? – Haxiel Oct 28 '20 at 17:58> {}.csv
will happen just once, outsidexargs
, and will redirect the output of all themdb-export ...
commands into a single file named exactly{}.csv
. – Oct 28 '20 at 18:15mdb-tables davidoff.mdb | xargs -I {} echo sh -c 'mdb-export davidoff.mdb "$1" > "$1.csv"' sh-c {}
(remove theecho
if the commands look OK) – Oct 28 '20 at 18:19-I
implies-L
, i.e. one line from standard input will be substituted to{}
. Assumingmdb-tables
andmdb-export
are from this project, the first command seems to expect one table as the second argument while the second command seems to output several tables on the same line (though I may be wrong on this). – fra-san Oct 28 '20 at 18:25echo
-prepended, dry-run command from my comment print? – Oct 29 '20 at 00:03xargs
are you using? – fra-san Oct 29 '20 at 10:22