zoukankan      html  css  js  c++  java
  • Linux里AWK中split函数的用法

    跟java里的split函数的用法是很相像的,举例如下:

    The awk function split(s,a,sep) splits a string s into an awk array a using the delimiter sep.

    set time = 12:34:56
    set hr = `echo $time | awk '{split($0,a,":" ); print a[1]}'` # = 12
    set sec = `echo $time | awk '{split($0,a,":" ); print a[3]}'` # = 56

    # = 12 34 56
    set hms = `echo $time | awk '{split($0,a,":" ); print a[1], a[2], a[3]}'`
    set hms = `echo $time | awk '{split($0,a,":" ); for (i=1; i<=3; i++) print a[i]}'`

  • 相关阅读:
    MVC ActionResult JsonResult
    xml文件
    使用socket实现聊天功能
    使用多线程完成Socket
    Socket编程
    U1总结
    多线程
    IO
    单例模式
    日期
  • 原文地址:https://www.cnblogs.com/mfryf/p/3559233.html
Copyright © 2011-2022 走看看