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.
2 comments:
Excellent Tip. I for one will implement this finding immediately as I have also been researching the Internet for awk related trivia.
Thanks Graham!
Actually, it's not a floor function, as
echo -3.5 | awk -F. '{print $1}'
prints -3, not -4, which would be floor(-3.5).
Post a Comment