1.shell 循环所有.txt重命名为.sql
#!/bin/bash #/home/test/ find ./ -name *.txt | while read i do echo "$i"; mv $i.txt $i.sql done
2.批量首行添加"charset utf8;"并导入
find ./ -name *.sql | while read i do sed -i '1icharset utf8;' "$line" mysql -uroot -hdb1 cake_yjiang < "$line" done