1

I have a lot of *.sql.gz files in directory (400+). How i can unzip all of them and then import to Mysql? I tried

gunzip -r < /share/new_moyo_ua | mysql -u root -proot new_moyo_ua

But this not work fine (gzip: stdin: Is a directory).

anhckie
  • 145
  • 3
  • I'd be surprized if this works, but did you try `gunzip -r < /share/new_moyo_ua/* | ...` ? I think you're going to have to set up a loop and `gunzip $file | mysql ... ` one at a time. Or, the preferred and bullet-proof solutions is `find /base/path/to/files -name '*.sql.gz' -print0 | while IFS= read -r -d '' file ; do gunzip -c "$file" | mysql ... ; done`. See https://stackoverflow.com/a/9612232/620097 for further discussion of processing lists inside loops (very good). Good luck! – shellter Sep 25 '20 at 14:59

1 Answers1

0
gunzip *.sql.gz
cat *.sql | mysql ...
Leandro Bardelli
  • 10,561
  • 15
  • 79
  • 116
ΔO 'delta zero'
  • 3,506
  • 1
  • 19
  • 31