calling function inside awk


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting calling function inside awk
# 1  
Old 04-14-2008
CPU & Memory calling function inside awk

Hi All,

My 1.txt contains some functions
fun1()
....
....

fun2()
....
....


I can call these fun from 2.txt inside awk as below
value="`fun1 "argument1"`"
awk 'BEGIN {printf ("%s", "'"$value"'")}'

I need to modify the above code so that without using the variable to store function return value, i can directly call the function inside the awk statement and print then and there.

Is this possible??

Can some one help me with this

Thanks in advance
JS
# 2  
Old 04-14-2008
Code:
awk 'BEGIN {printf ("%s", "'"`fun1 "argument1"`"'")}'


Last edited by era; 04-14-2008 at 01:00 PM.. Reason: Missing close /CODE tag
# 3  
Old 04-14-2008
Thank you so much era !!!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need help on awk for printing the function name inside each function

Hi, I am having script which contains many functions. Need to print each function name at the starting of the function. Like below, functionname() { echo "functionname" commands.... } I've tried like below, func=`grep "()" scriptname | cut -d "(" -f1` for i in $func do nawk -v... (4 Replies)
Discussion started by: Sumanthsv
4 Replies

2. Shell Programming and Scripting

Help to Modify File Name in each function before calling another function.

I have a script which does gunzip, zip and untar. Input to the script is file name and file directory (where file is located) I am reading the input parameters as follows: FILENAME=$1 FILEDIR=$2 I have created 3 functions that are as follows: 1) gunzip file 2) unzip file... (2 Replies)
Discussion started by: pinnacle
2 Replies

3. Shell Programming and Scripting

Calling a function in cpp file inside shell script

Hi I need to call a function written in a cpp file with arguments inside the shell script..Can anyone help me how to do this:( (1 Reply)
Discussion started by: rkrish
1 Replies

4. Shell Programming and Scripting

Calling array inside awk

Hello I have the file df.tmp FS is actually the / FS but escape character\ and end of line $ is used in order to fetch exctly / and not other filesystems. awk '/\/$/ {print $(NF-1)+0}' df.tmp will work properly and return a value eg. 60 but when I am trying to issue the command with the array... (3 Replies)
Discussion started by: drbiloukos
3 Replies

5. Shell Programming and Scripting

SHELL SCRIPT Function Calling Another Function Please Help...

This is my function which is creating three variables based on counter & writing these variable to database by calling another function writeRecord but only one record is getting wrote in DB.... Please advise ASAP...:confused: function InsertFtg { FTGSTR="" echo "Saurabh is GREAT $#" let... (2 Replies)
Discussion started by: omkar.sonawane
2 Replies

6. Shell Programming and Scripting

Calling function in awk statement.

Hi All, I have an awk statement and a function defined in a script. I am trying to call the function from inside awk statement, i.e. awk ' myFunk () ;' filename But when I define myFunk() before awk, then I receive this error: s2.sh: line 48: syntax error: unexpected end of file and... (5 Replies)
Discussion started by: morningSunshine
5 Replies

7. Shell Programming and Scripting

calling a method inside awk

Hi All, How do we call a method existing in another file inside awk. After matching a pattern i want to call a method secureCopy that exists in another file, but method not getting called: ls -l | awk -v var2=$servername -v var1=$srcserverpath -v var3=$tgtpath '... (1 Reply)
Discussion started by: abhinav192
1 Replies

8. Shell Programming and Scripting

Return a value from called function to the calling function

I have two scripts. script1.sh looks -------------------------------- #!/bin/bash display() { echo "Welcome to Unix" } display ----------------------------- Script2.sh #!/bin/bash sh script1.sh //simply calling script1.sh ------------------------------ (1 Reply)
Discussion started by: mvictorvijayan
1 Replies

9. Shell Programming and Scripting

Function's return value used inside awk

I have a file with the record of person: cat > $TMP/record.txt John Torres M Single 102353 Address Mark Santos M Maried 103001 Address Carla Maria F Maried 125653 Address #!/bin/ksh ManipulateID(){ ... return 0; ... #or return 1; } cat $TMP/record.txt | awk 'BEGIN {printf... (4 Replies)
Discussion started by: Orbix
4 Replies

10. UNIX for Advanced & Expert Users

calling external values inside awk command

I have a code as follows awk ' BEGIN{FS=OFS=","} { n=split($3,a1,"~") split($4,a2,"~") split($5,a3,"~") for(i=1;i<=n;i++) { print $1,$2,a1,a2,a3,date } }' file In the above code I need to add current date(date). How is this possible to call an date or a exported value... (13 Replies)
Discussion started by: tkbharani
13 Replies
Login or Register to Ask a Question