zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    UVA11464偶数矩阵
    UVA11464偶数矩阵
    UVA11462年龄排序
    UVA11462年龄排序
    UVA11427玩纸牌(全概率+递推)
    UVA11427玩纸牌(全概率+递推)
    UVA11389巴士司机问题
    LA3644简单并查集判环
    LA3027简单带权并查集
    LA3027简单带权并查集
  • 原文地址:https://www.cnblogs.com/chuanzhang053/p/10232773.html
Copyright © 2011-2022 走看看