# Awk type checking

**URL:** <https://community.unix.com/t/awk-type-checking/170509>\
**Category:** Shell Programming and Scripting\
**Created:** [April 13, 2007, 1:13am UTC](https://community.unix.com/t/awk-type-checking/170509 "2007-04-13T01:13:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![scotty\_123](https://community.unix.com/letter_avatar/scotty_123/32/6_22734026db12803ebb3e059622ac3534.png) [@scotty\_123](https://community.unix.com/u/scotty_123)\
**Post date:** [April 13, 2007, 1:13am UTC](https://community.unix.com/t/awk-type-checking/170509/1 "2007-04-13T01:13:12Z")

</div>

Hello,

How to check if two variables( fields in awk) have the same datatype ( INTEGER , REAL, TEXT ) ?

---

<div class="post-metadata">

**Author:** ![Ygor](https://community.unix.com/user_avatar/community.unix.com/ygor/32/104_2.png) [@Ygor](https://community.unix.com/u/Ygor)\
**Post date:** [April 13, 2007, 1:25am UTC](https://community.unix.com/t/awk-type-checking/170509/2 "2007-04-13T01:25:10Z")

</div>

Awk has no typing.

---

<div class="post-metadata">

**Author:** ![anbu23](https://community.unix.com/user_avatar/community.unix.com/anbu23/32/351_2.png) [@anbu23](https://community.unix.com/u/anbu23)\
**Post date:** [April 13, 2007, 1:34am UTC](https://community.unix.com/t/awk-type-checking/170509/3 "2007-04-13T01:34:05Z")

</div>

```nohighlight
$ cat file
12
23.34
asasa
12
23.23
23.34
a.asa
12asa
$ awk ' $1 ~ /^[0-9]+$/ { print $1" no" ; next }
> $1 ~ /^[0-9]+.[0-9]+$/ { print $1" real"; next }
> { print $1" alpha" } ' file
12 no
23.34 real
asasa alpha
12 no
23.23 real
23.34 real
a.asa alpha
12asa alpha

```
