![]() |
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 |
| Passing global variable to a function which is called by another function | sars | Shell Programming and Scripting | 4 | 06-30-2008 12:39 PM |
| create a thread from a returning function | wolwy_pete | High Level Programming | 3 | 05-08-2008 04:48 AM |
| How to create SQRT function in catenate file | ahjiefreak | Shell Programming and Scripting | 7 | 12-10-2007 12:31 PM |
| create thread C with JNI function with JAVA | AUBERT | HP-UX | 0 | 08-06-2004 06:24 AM |
| How do I create desktop icons for the shell programs I create??? | TRUEST | UNIX Desktop for Dummies Questions & Answers | 7 | 05-15-2002 12:40 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
create function with awk
hi all,
i print four variable delimited by comma with awk : awk -F "," '{print $1;$2;$3;$4}' ' if $3="" code ... } i want to extract this information from another file using another awk using the $1 printed awk -v { code } but the problem i can't use two awk in the same code in shell script. how can i create a function using the second awk and after that call it in the first awk traitement. thanks |
|
||||
|
As mentioned an idea of what you are doing and have done would help. This example may help you in any case. It's a useless exercise but demonstrates what you *may* be wanting in principle. Tested only for gawk.
Code:
function getlines_from(fname,arr,p,fldlimit ,i) {
while ( (getline < fname) > 0) {
for (i=0 ; i <= fldlimit ; i++) {
if (i == 0) {arr[p++] = " Next record group for working file " fname; i++}
arr[p++] = $i
}
}
return p
}
BEGIN {
x=0
g=0
f=0
record[g]=""
for (x=1 ; x < ARGC ; x++) {
f = getlines_from(ARGV[x],record,g,6)
g = f
close(ARGV[x])
}
#for (f=1 ; f < g ; f++) {print f,record[f]}
}
{
for (j=1 ; j <= 6 ; j++) {
for (ab in record)
if (record[ab] == $j) {printf "Match at %s, with indice %d for field $%d\n",record[ab],ab,j}
}
}
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|