The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Passing global variable to a function which is called by another function sars Shell Programming and Scripting 4 06-30-2008 08:39 AM
function help coolkid Shell Programming and Scripting 2 05-01-2008 10:47 AM
Log function Ernst Shell Programming and Scripting 17 03-19-2007 08:31 AM
Function within function (Recurance) chassis UNIX for Dummies Questions & Answers 2 09-19-2006 06:32 AM
How to convert the "select" function into a "poll" function rbolante High Level Programming 1 07-10-2001 07:49 AM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-04-2008
Registered User
 

Join Date: Dec 2007
Posts: 57
help function

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
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 01-04-2008
Registered User
 

Join Date: Sep 2006
Posts: 1,445
where did you get $file1
Reply With Quote
  #3 (permalink)  
Old 01-04-2008
radoulov's Avatar
addict
 

Join Date: Jan 2007
Location: Milan, Italy/Varna, Bulgaria
Posts: 1,432
If I understand correctly:

Code:
% 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
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 08:26 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0