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
sample files, pls - and the desired result based on the samples.
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.
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}
}
}