在Mawk中使用strftime函数 [英] Using strftime function in mawk

查看:421
本文介绍了在Mawk中使用strftime函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建AWK脚本,该脚本将根据某种模式过滤输入文件,并使用strftime()函数进行某些计算.

I'm trying to create AWK script that will filter the input file according to some pattern, and use the strftime() function for some calculations.

($2 ~ /^[HB]/ && $2 ~ /n$/){
        print strftime("%Y")
}

使用的口译员是mawk. 使用以下命令触发此脚本时:

The interpreter in use is mawk. When triggering this script using this command:

awk -f script3 inputFile

我遇到错误:函数strftime从未定义"

I'm getting the error: "function strftime never defined"

推荐答案

安装GAWK将使您获得函数strftime,而您原来在awk中就缺少该功能.

Installing GAWK will get you the function strftime back that you are missing natively in awk.

使用Ubuntu 11.10或类似发行版,您将发出以下命令来获取GAWK

With Ubuntu 11.10 or simiar distribution you would issue following command to get the GAWK

sudo apt-get install gawk

您也可以在gawk中使用它,但不必这样做,只需继续使用原始的awk脚本即可.

You can also use it in gawk however you don't have to and can simply go ahead with your original awk script.

这篇关于在Mawk中使用strftime函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆