reticentfat
V2EX  ›  问与答

linux 下如何截取字符串

  •  
  •   reticentfat · Aug 25, 2015 · 3077 views
    This topic created in 3960 days ago, the information mentioned may be changed or developed.
    txt 文件里边有 A,B,C 三个字段如下
    19 Y35U688 您好,提醒您: 15 年 08 月 12 日,小型汽车粤 Y53U66 在
    怎么能把车牌号即粤 Y35U68 提取出来
    2 replies    2015-08-26 13:29:41 +08:00
    reticentfat
        1
    reticentfat  
    OP
       Aug 25, 2015
    写出来了
    bzcat a.txt.bz2 | iconv -f utf-8 -t gbk | awk -F'\t' '{print $3}' | awk -F',' '{print $3}'| awk '{print substr ($0,index ($0,"粤"),index ($0,"在")-5 )}'
    21grams
        2
    21grams  
       Aug 26, 2015
    一句话三个号码居然个个不同,也是服了。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   822 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 37ms · UTC 20:44 · PVG 04:44 · LAX 13:44 · JFK 16:44
    ♥ Do have faith in what you're doing.