Last active
August 29, 2015 14:24
-
-
Save safecat/e7bee1345085cecd5ca3 to your computer and use it in GitHub Desktop.
从mysqldump导出的sql文件中移除一些数据库
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 第一步,找出所有库所在的行号 | |
| cat all_databases.sql |grep -n "Current Database" | |
| #返回 | |
| 422:-- Current Database: `data_platform` | |
| 8094:-- Current Database: `mysql` | |
| 13013:-- Current Database: `test` | |
| 13045:-- Current Database: `test_insert` | |
| 13085:-- Current Database: `test_l5` | |
| # 第二步,确认要移除的库:mysql | |
| # 该库的字符区间在8094-13012 | |
| # 第三步,使用sed移除 | |
| sed -e '8094,13012d' all_databases.sql > all_databases_except_mysql.sql |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment