# Global Variable in awk...

**URL:** <https://community.unix.com/t/global-variable-in-awk/172718>\
**Category:** Shell Programming and Scripting\
**Created:** [July 4, 2007, 12:01pm UTC](https://community.unix.com/t/global-variable-in-awk/172718 "2007-07-04T12:01:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ZINGARO](https://community.unix.com/letter_avatar/zingaro/32/6_449c533f586939b6e5f246632a46421f.png) [@ZINGARO](https://community.unix.com/u/ZINGARO)\
**Post date:** [July 4, 2007, 12:01pm UTC](https://community.unix.com/t/global-variable-in-awk/172718/1 "2007-07-04T12:01:01Z")

</div>

i think.....

it's possible use a variable out a awk in the awk ???

ex.

A=20071225

awk '{ print "the value is" $a }'  
OR  
awk '{ print "........"; c=10; print $c ; c=$A ; print $A}'

for a external variable is possbile use in the awk ???

---

<div class="post-metadata">

**Author:** ![aigles](https://community.unix.com/user_avatar/community.unix.com/aigles/32/118_2.png) [@aigles](https://community.unix.com/u/aigles)\
**Post date:** [July 4, 2007, 1:07pm UTC](https://community.unix.com/t/global-variable-in-awk/172718/2 "2007-07-04T13:07:14Z")

</div>

You can do :

```nohighlight
A=20071225
awk '{ print "the value of A is" '"$A"' }' infile

```

Or

```nohighlight
A=20071225
awk -v A="$A" '{ print "........"; c=10; print $c ; c=A ; print A}' infile

```

or

```nohighlight
A=20071225
awk '{ print "........"; c=10; print $c ; c=A ; print A}' A="$A" infile

```

or

```nohighlight
export A=20071225
awk '{ c=ENVIRON["A"] + $1; print c}' infile

```
