Hi,
1) I would like to execute in gawk a shell command looking like this:
---------------------------------------------------------------
#!/bin/gawk -f
begin{
system("echo 'test' | gawk '{print $0}'")
}
---------------------------------------------------------------
but I get this error message:
---------------------------------------------------------------
gawk: cmd. line:1: '{print
gawk: cmd. line:1: ^ invalid char ''' in expression
---------------------------------------------------------------
2) How define functions in BEGIN{}
For example :
---------------------------------------------------------------
#!/bin/gawk -f
begin{
func test(var) # definition of some function
{
if (match($0,var)!=0)
{
print NR":\t"$0
}
}
while ("cat testfile" | getline > 0) # execution of this function
using the output of "cat filetest"
{
test("foo")
}
}
---------------------------------------------------------------
Or how to define a function we need to use in BEGIN{} ?
1) I would like to execute in gawk a shell command looking like this:
---------------------------------------------------------------
#!/bin/gawk -f
begin{
system("echo 'test' | gawk '{print $0}'")
}
---------------------------------------------------------------
but I get this error message:
---------------------------------------------------------------
gawk: cmd. line:1: '{print
gawk: cmd. line:1: ^ invalid char ''' in expression
---------------------------------------------------------------
2) How define functions in BEGIN{}
For example :
---------------------------------------------------------------
#!/bin/gawk -f
begin{
func test(var) # definition of some function
{
if (match($0,var)!=0)
{
print NR":\t"$0
}
}
while ("cat testfile" | getline > 0) # execution of this function
using the output of "cat filetest"
{
test("foo")
}
}
---------------------------------------------------------------
Or how to define a function we need to use in BEGIN{} ?