Shell and Awk arguments question

Shell and Awk arguments question

Post by s.. » Fri, 28 May 1993 20:13:46



hello,

Here's a problem I need help with. I am parsing some arguments
through an awk program, some of these arguments need to be processed
in a shell program but I do not know how to export the arguments
from the awk program to the shell program.

One method that is working is the following, write the argument
to a datafile from awk, then
        xargs shell_program <datafile_from_awkprogram

However, I would like to be able to do the following,
        xargs awk_program | shell_program
So far, I have been unsuccessful.

The basic problem is that of reading std input through a pipe
or a datafile rather than the command line. Also raises question
about how to redirect a shell instead reading without using sub-shells.
Thanks for your help.

Regards,

Sunita Yadav

P.S. please post directly to me.

 
 
 

Shell and Awk arguments question

Post by gseid.. » Wed, 02 Jun 1993 10:33:25



>hello,

>Here's a problem I need help with. I am parsing some arguments
>through an awk program, some of these arguments need to be processed
>in a shell program but I do not know how to export the arguments
>from the awk program to the shell program.

>One method that is working is the following, write the argument
>to a datafile from awk, then
>    xargs shell_program <datafile_from_awkprogram

>However, I would like to be able to do the following,
>    xargs awk_program | shell_program
>So far, I have been unsuccessful.

>The basic problem is that of reading std input through a pipe
>or a datafile rather than the command line. Also raises question
>about how to redirect a shell instead reading without using sub-shells.
>Thanks for your help.

>Regards,

>Sunita Yadav

>P.S. please post directly to me.


 
 
 

1. awk shell argument passing question

I need help on how to pass an argument to an AWK script.
I am running K-shell on a Sparcstation.
I want to type in something like: getfun1 loglex
where getfun1 is my shell script containing an AWK program.
The AWK program is to search for the string loglex.
I got it to work using the shell but could not make it
work using the ARGV[1] or variablename= in AWK.

The program below works:
------------------------------------------------------------------
awk " #double quotes allow shell to expand dollar 1 below
#usage: type this file name followed by functon name
#to search for e.g. getfun1 loglex
#the function declaration line will be printed
BEGIN   {
                print $1
                }
/^$1\(/ { # search for function name
                                "'print $0  '" # must protect dollar zero from shell
                                }
"
-------------------------------------------------------------------
I can't get any manner of myfunc=ARGV[1] etc to work, even though
I have read pp. 65-66 of the AWK book and tried using the
variable= option also.

Any help would be appreciated.  I couldn't
find any comp.lang.awk, so it ended up here.

--
Craig F. Taylor

Work (612) 895-2254
Home (612) 454-4994

2. 3com Etherlink XL PCI

3. passing arguments between Unix shell and Awk

4. Block device over the network

5. AWK: How to pass command line arguments to awk

6. Windows Manager

7. awk question: getline with no argument

8. Just Another Clueless Newbie

9. sh & awk: Quoting Awk Syntax in Bourne shell?

10. QUESTION : Passing arguments to korn shell aliases?

11. script questions - passing argument as argument to another program

12. Bourne shell script affecting current shell with arguments

13. shell - sed - awk question