Article View: comp.lang.misc
Article #3435awk
From: Hal Moroff
Date: Tue, 09 Apr 1991 23:07
Date: Tue, 09 Apr 1991 23:07
42 lines
1650 bytes
1650 bytes
I'm trying to use awk to read an ascii file, and translate only
certain fields. I have my own special filter that will be used for the
translation.
I can get awk to read my input file and extract the desired fields.
I can also get it to invoke my filter passing those fields, however I cannot
get the filter return value assigned to a variable in my awk program.
My hands are slightly tied in that I cannot modify the way the
filter works.
An awk code fragment follows:
-------------------------------------------------------------------------------
#
# awk script to filter selected fields
#
#
BEGIN { }
/.*/ {
# the following statement works whether I use 'cat' or my own filter
print ">> " $1 | "cat"
# however I wish to retrieve the string output by my filter into
# a variable for further processing by 'awk'. I've tried:
# print ">> " $1 | "cat" | getline
# and also:
# print ">> " $1 | "cat" | getline str
# and both return the same error:
#awk: syntax error near line 14
#awk: illegal statement near line 14
}
END { }
-------------------------------------------------------------------------------
Sorry if this distribution is too wide/narrow. I've read notes
a long time, and posted rarely.
Reply by email here or to cognex!hal@ai.mit.edu
Thanx.
- hal
Technical Details
Message-ID:
<1182@junkyard.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!bu.edu!m2c!jjmhome!junkyard!halShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!bu.edu!m2c!jjmhome!junkyard!hal From: hal@junkyard.UUCP (Hal Moroff) Newsgroups: comp.lang.misc Subject: awk Message-ID: <1182@junkyard.UUCP> Date: 9 Apr 91 23:07:02 GMT Reply-To: hal@junkyard.UUCP (Hal Moroff) Organization: Junkyard Lines: 42