Showing posts with label math. Show all posts
Showing posts with label math. Show all posts

Thursday, 11 March 2010

Using awk as a floor function

I was searching the internet trying to find out if awk had a floor function when I realised awk IS a floor function.



graham@graham-laptop:~$ x=3.5
graham@graham-laptop:~$ echo $x | awk -F. '{print $1}'
3
graham@graham-laptop:~$

You could always change $1 for $2 and it becomes a mod function.