argv 
Author Message
 argv

Hi.
I'm using to process maillog file. I need to invoke awk with the source awk
code ( option -f ), input file and an extra argument that must be used in a
conditional sentence.
I thought that "awk -f source_code input_file arg" is the solution but only
obtain a parse error.

Who can help me?

   Thanks in advance.



Fri, 10 Jan 2003 03:00:00 GMT  
 argv
Quote:

> Hi.
> I'm using to process maillog file. I need to invoke awk with the source awk
> code ( option -f ), input file and an extra argument that must be used in a
> conditional sentence.
> I thought that "awk -f source_code input_file arg" is the solution but only
> obtain a parse error.

> Who can help me?

>    Thanks in advance.

The obvious answer is:
    awk -f source_file -v var=arg input_file
and then reference var to obtain the value arg. This works equally well
with simple arguments (var=jones), more complex data
(var="jones,28,test") and shell variables (var=$1). Only in some awks is
the data available in the BEGIN block, YMMV.
--
Bob Stearns
University of Georgia

(706)542-5110


Fri, 10 Jan 2003 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. sys.argv[0] - 'module' object has no attribute 'argv'

2. argv filename for J7

3. gawk problem retrieving ARGV (Sun vs Linux)

4. Crazy ARGC/ARGV behavior

5. ARGV question

6. gawk executable scripts and ARGV[0]

7. ArgC/ArgV - Command Line Parsing

8. : Passing array to C func() expecting argv

9. Forth argv and argc

10. Equivalent of argv(0) in Clipper/Xbase++ ???

11. Syntax Question: ARGV/ARGC for Eiffel

12. Problem w ruby_options(argc, argv) in embedded Ruby app

 

 
Powered by phpBB® Forum Software