Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google site



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

Closed Thread
English Japanese Spanish French German Portuguese Italian Powered by Powered by Google
 
Thread Tools Search this Thread Rate Thread 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
Sponsored Links
  #2 (permalink)  
Old 01-04-2008
Registered User
 

Join Date: Sep 2006
Posts: 2,604
where did you get $file1
  #3 (permalink)  
Old 01-04-2008
radoulov's Avatar
--
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 3,214
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

Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


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 12:39 PM
function help coolkid Shell Programming and Scripting 2 05-01-2008 02:47 PM
Log function Ernst Shell Programming and Scripting 17 03-19-2007 12:31 PM
Function within function (Recurance) chassis UNIX for Dummies Questions & Answers 2 09-19-2006 10:32 AM
How to convert the "select" function into a "poll" function rbolante Programming 1 07-10-2001 11:49 AM



All times are GMT -4. The time now is 08:19 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2010. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0