Hacker News new | ask | show | jobs
by Brentward 2021 days ago
Not that this is an important part of the post, but in general parsing the output of ls like the author does in the for loop is a bad idea[1].

I think the one-liner would be better as

  for i in [0-8]*/*.sql; do psql -U <user> -h localhost -d <dbname> -f $i ; done
or even better as something like

  find . -name "*.sql" -exec psql -U <user> -h localhost -d <dbname> -f {} \;
[1] http://mywiki.wooledge.org/ParsingLs