Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using bangpath and multiple -f's

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
hello, I use awk for little cgi-scripts. I made some awk-libs, now I want to include them in my script.

#!/usr/bin/awk -f
...rest of the script...

works fine.

When I try to include one or more libs, it fails miserably:

#!/usr/bin/awk -f lib1.awk -f lib2.awk -f
...rest of my script...

I tried this with gawk and mawk, none of them work. The manpages of mawk say that multiple -f's are allowed.
Could anyone find the proper syntax for this, or do I have to escape it in a way because it is in the bangpath of my executable?

GruBen,
Pirre <kbr@sjca.edu.eu.org>

PS. Please send me a mail too with an answer
 
The -f parameter is used for one or more input files.

However, multiple awk/mawk/gawk... scripts cannot be
executed in one call. I suggest you set up a shell
wrapper that includes your lib scripts along these lines:

gawk '/blah/ {print}' | gawk '/xxx/ {action}' |gawk '/yep/ {if(true) print}' file1 > file2

In this way you build your output file sequentially by
processing the results of the previous gawk script all
in one call to the shell file.

Hope this helps you!
 
Also, don't forget the interpretation of the #! line ... there is usually a limit to the number of characters after the command that is based to the shell by exec(2). And sometimes the number of arguments is limited. You can test this by creating an &quot;echo&quot; script:

#! /usr/bin/echo this is a test, this is only a test

-- D
[sig]<p>Derek Ludwig<br><a href=mailto:derek@ludwig.com>derek@ludwig.com</a><br><a href= > </a><br> [/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top