Home > Archive > AWK > June 2007 > Execute command within AWK
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Execute command within AWK
|
|
| Prateek 2007-06-07, 9:57 pm |
| Hi,
Is it possible for me to invoke other commands/scripts from gawk. For
example can I invoke "grep" or "wc" from within awk like
gawk '{grep ....}' file 1
"grep" and "wc" are just mentioned as an example. But the question is
about invoking commands/scripts from awk.
Thanks,
Prat
| |
|
|
| Ted Davis 2007-06-07, 9:57 pm |
| On Wed, 06 Jun 2007 12:36:14 -0700, Prat <prat .a@gmail.com>
wrote:
>Hi,
>Is it possible for me to invoke other commands/scripts from gawk. For
>example can I invoke "grep" or "wc" from within awk like
>
>gawk '{grep ....}' file 1
>
>"grep" and "wc" are just mentioned as an example. But the question is
>about invoking commands/scripts from awk.
>
grep is a poor example - wc is only somewhat less so because of the
large overlap in functionality.
However, wget is a good example - this is composite code from several
scripts:
WgetCommand = "wget -t 3 -T 30 -O- -U \"Mozilla/5.0
(Windows; U; Windows NT 5.1; en-US; rv:1.8.1.2) Gecko/20070219
Firefox/2.0.0.2\" http://www.wire-heads.com/istrip/ 2>"
StdErrFile = Array[ 4 ] ".response"
WgetCommand = WgetCommand StdErrFile
while( ( WgetCommand | getline ) > 0 ) {
if( !x ) {
if( match( tolower( $0 ),
/comic?[sx]?[0-9]?[\/=]([a-z0-9\-_\/]+)\./, Arr ) ) x = Arr[1]
}
(Actually, that is not working code because that test doesn't go with
that URL.)
--
T.E.D. (tdavis@gearbox.maem.umr.edu)
Remove "gearbox.maem." from address - that one is dead
| |
|
|
|
|
|
|
|