Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using strftime function in mawk

Tags:

strftime

awk

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")
}

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

awk -f script3 inputFile

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

like image 823
Ariel.T Avatar asked Sep 10 '10 11:09

Ariel.T


1 Answers

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

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

sudo apt-get install gawk

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

like image 197
Kamran Avatar answered Sep 20 '22 07:09

Kamran