View Single Post
  #1   (View Single Post)  
Old 6th July 2011
Oko's Avatar
Oko Oko is offline
Rc.conf Instructor
 
Join Date: May 2008
Location: Kosovo, Serbia
Posts: 1,102
Default AWK passing the argument to system command

I was wondering if somebody could tell me if there is a way to pass argument to a system command in AWK. Namely, let suppose that I want to print calendar for September-November of 2011. I can do that with

Code:
#!/usr/bin/awk -f

BEGIN {FS=" "; OFS=""}
{
        system("cal 8 2011")
        system("cal 9 2011")
        system("cal 10 2011")
        system("cal 11 2011")
}
However I would like to be able to do something like
Code:
#!/usr/bin/awk -f

BEGIN {FS=" "; OFS=""}
{
{ for (i = 8; i <= 11; i++)
        system("cal $i 2011")
}
}
I also tried

Code:
#!/usr/bin/awk -f

BEGIN {FS=" "; OFS=""}
{
{ for (i = 8; i <= 11; i++)
        system("cal"  i "2011")
}
}
but no luck.

Anybody knows how to do this?

P.S. I am not interesting in the shell script or anything else. I want to do this with AWK.
Reply With Quote