Shell in a large file find the desired string manipulation tips

Source: Internet
Author: User

Yesterday, the Dragon Boat Festival, the evening when a phone call, my friend's company, the database was two work not long phper to break, the specific is to put a field value, to the whole table into a name, of course, this is can be configured to prohibit the whole table update database, this can be nasty, find me, call me to see, They have a backup every day 3:00, by day backup, fortunately not incremental, of course, Binlog log is also open, I looked at their backup file is

[Email protected] ~]# ls-lha/www/datebak/. sql14. 9G June  9:/www/datebak/ ---   ~]#

Their entire backup file has 5G, of course, the effect of recovery has a variety of, I think about them today this day of the registration of users to get out, and not much more than 10, and then is to find a way to the 5 g of the data I need to look for the table.

[Email protected] datebak]# grep-n"ROP TABLE IF EXISTS ' activity '"  .- .- the. SQL-Bash:activity:command not found A:D rop TABLE IF EXISTS ' activity '; the:D rop TABLE IF EXISTS ' activity_img '; the:D rop TABLE IF EXISTS ' activity_recommended ';124:D rop TABLE IF EXISTS ' atest ';149:D rop TABLE IF EXISTS ' black_user ';175:D rop TABLE IF EXISTS ' category ';204:D rop TABLE IF EXISTS ' Class_grade ';232:D rop TABLE IF EXISTS ' Collocate_banner ';262:D rop TABLE IF EXISTS ' course '; the:D rop TABLE IF EXISTS ' edu_account_bind ';366:D rop TABLE IF EXISTS ' function ';392:D rop TABLE IF EXISTS ' head_img ';418:D rop TABLE IF EXISTS ' information ';455:D rop TABLE IF EXISTS ' information_img ';480:D ROP TABLE IF EXISTS ' Installed_app ';

With the shell grep This command, we can figure out the number of rows in the table we need

sed ' 5112,5153p ' -Tb_user_info.sql-SQL> 

Then through the SED command will we find the line number written to another file, so that the basic solution, and then, I sent out the data to import the original data, and then the export of the day's data to import, solved the problem, the whole problem-solving time, not more than 1 hours, mainly the shell has not been commonly used , but also check the information, of course, the idea is also the most important, solve the problem, the first, to have a clear analysis of the idea, the whole process, good over a few, otherwise, the examination is not complete, will cause more problems

Shell in a large file find the desired string manipulation tips

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.