darold / pgFormatter

A PostgreSQL SQL syntax beautifier that can work as a console program or as a CGI. On-line demo site at http://sqlformat.darold.net/
PostgreSQL License
1.66k stars 100 forks source link

Run recursively on directory #309

Open kevinmichaelchen opened 1 year ago

kevinmichaelchen commented 1 year ago

Is it possible to run this recursively on all SQL files under a directory?

darold commented 1 year ago

Something like that should do the work:

find mydir/ -name '*.sql' | xargs -i pg_format -o {}.out {}

the formatted files will have the extension .out or if you want to override the existing SQL files you can do something like that:

find mydir/ -name '*.sql' | xargs -i pg_format -i {}