# help function

**URL:** <https://community.unix.com/t/help-function/180523>\
**Category:** Shell Programming and Scripting\
**Created:** [January 4, 2008, 5:27am UTC](https://community.unix.com/t/help-function/180523 "2008-01-04T05:27:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kamel.seg](https://community.unix.com/letter_avatar/kamel.seg/32/5_5575768a8748004e209b776fc1b2916d.png) [@kamel.seg](https://community.unix.com/u/kamel.seg)\
**Post date:** [January 4, 2008, 5:27am UTC](https://community.unix.com/t/help-function/180523/1 "2008-01-04T05:27:42Z")

</div>

i have a file like :

File1

var1,var2,var3  
var4,var5,var6  
var7,var7,var8  
.  
.  
.

$3 : var3,var6,var8, may be null in this file so when it's nul i get the information from a function serach () which return $var i want to print it in $3

i do like that :

awk -F "," '{ {first=$1; sec=$2; tro=$3 }  
if (tro == "")  
{

search ( parametre)  
{print $1","$2","$var} }  
else  
{print $1","$2","$3 }}' $file1 \> $file

but i doesn't print $var in $file.

any help please

---

<div class="post-metadata">

**Author:** ![ghostdog74](https://community.unix.com/letter_avatar/ghostdog74/32/5_5575768a8748004e209b776fc1b2916d.png) [@ghostdog74](https://community.unix.com/u/ghostdog74)\
**Post date:** [January 4, 2008, 6:49am UTC](https://community.unix.com/t/help-function/180523/2 "2008-01-04T06:49:08Z")

</div>

where did you get $file1

---

<div class="post-metadata">

**Author:** ![radoulov](https://community.unix.com/user_avatar/community.unix.com/radoulov/32/489_2.png) [@radoulov](https://community.unix.com/u/radoulov)\
**Post date:** [January 4, 2008, 6:51am UTC](https://community.unix.com/t/help-function/180523/3 "2008-01-04T06:51:00Z")

</div>

If I understand correctly:

```nohighlight
% cat data 
var1,var2,
var4,var5,var6
var7,var7
var7,var7,var8
% var="whatever"
% awk '!$3{$3=v}1' OFS="," FS="," v="$var" data
var1,var2,whatever
var4,var5,var6
var7,var7,whatever
var7,var7,var8

```
