linux环境下,对于一个大文件,如何查看其中某行的内容

需求说明

  今天在做mysql数据导入的过程中,导入到最后有一个报错,报某张表不存在。然后就想看看这行到底是在做什么操作的时候报的错误。

报错信息

[mysql@host-10-191-36-11 ~]$ cat nohup.out 
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1146 (42S02) at line 5926: Table 'prod.pm_store_chnl_relation' doesn't exist   #通过报错信息可以知道,在5926行有报错。因为文件太大,vi太慢。

 1.通过sed命令来打印5926行的内容

[mysql@host-10-191-36-11 ~]$ sed -n '5926 p' Backup_sysman_20190106_212506.sql 
/*!50001 CREATE ALGORITHM=UNDEFINED */

备注:发现仅有这一样无法定位,增加范围,多打印几行内容。

2.通过sed命令,打印5926到5930这5行的内容

[mysql@host-10-191-36-11 ~]$ sed -n '5926,5930 p' Backup_sysman_20190106_212506.sql 
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `pm_store_chnl_lon_lat` AS select distinct `b`.`CHNL_ID` AS `CHNL_ID`,`a`.`LATITUDE` AS `LATITUDE`,`a`.`LONGITUDE` AS `LONGITUDE` from (`sysman`.`sc_depart` `a` join `prod`.`pm_store_chnl_relation` `b`) where (`a`.`DEPART_ID` = `b`.`STORE_ID`) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;

 备注:通过这个信息也就是知道了哪里有问题了。

 

小结

  通过sed打印指定行号的内容  sed -n 'xp'  xxxx.xxx

  通过sed打印某个范围内的内容  sed -n 'x,yp' xxx.xxx

 

文档创建时间:2019年1月7日13:33:25

posted @ 2019-01-07 13:39  Zhai_David  阅读(3722)  评论(0编辑  收藏  举报