![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| function return array | dophine | Shell Programming and Scripting | 6 | 05-06-2008 12:16 PM |
| Function to return an array of integer | dwgi32 | High Level Programming | 2 | 11-20-2007 02:08 AM |
| need help with User Defined Function | user_prady | Shell Programming and Scripting | 11 | 11-18-2007 08:51 PM |
| User defined signal 1 | nitesh_raj | AIX | 0 | 01-29-2005 02:20 AM |
| Nawk user-defined function | NewbieGirl | Shell Programming and Scripting | 1 | 06-20-2003 10:51 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Hello Friends,
Is it possible to return an array from a user defined function in awk ? example: Code:
gawk '
BEGIN{}
{
catch_line = my_function(i)
print catch_line[1]
print catch_line[2]
print catch_line[3]
}
function my_function(i)
{
print "echo"
line[1]= "awk"
line[2]= "gawk"
line[3]= "nawk"
return line
}
' filename
Pls help.. Thanks in advance.. |
|
||||
|
no need to return
Hi,
I am not very sure about your req. But actually there is no need to return. The variable in your user-defined function will be recognized by awk. You can just deal with any variable in function, and out of function in awk other parts you can refer to it. Just modify your code to follow: gawk ' BEGIN{} { my_function(i) print line[1] print line[2] print line[3] } function my_function(i) { print "echo" line[1]= "awk" line[2]= "gawk" line[3]= "nawk" }' filename |
|
||||
|
Quote:
Thanks summer_cherry........ |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|