mercredi 15 avril 2015

Using xargs with multiple arguments

I'm trying to dump a load of sqlite tables to .csv format from the cmd line using xargs, i.e.



find . -name "*.db" -print0 | xargs -0 -I {} sqlite3 -header -csv {} "select * from pulse_data;" > {}.csv


for some reason its writing to {}.csv rather than each .db file in turn


Is there a problem with using the {} notation more than once?


If I run it without the redirect it seems to work as expected, i.e.



find . -name "*.db" -print0 | xargs -0 -I {} sqlite3 -header -csv {} "select * from pulse_data;"


just prints all the .db tables to stdout as expected in .csv format


How can i get it to redirect to a suitably named file, i.e. .db.csv?


Aucun commentaire:

Enregistrer un commentaire