Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!think!mit-eddie!genrad!decvax!wanginst!masscomp!leiby From: leiby@masscomp.UUCP (Mike Leibensperger) Newsgroups: net.unix Subject: Re: passing command line arguments to awk Message-ID: <1118@masscomp.UUCP> Date: Mon, 22-Sep-86 17:29:56 EDT Article-I.D.: masscomp.1118 Posted: Mon Sep 22 17:29:56 1986 Date-Received: Tue, 23-Sep-86 07:45:39 EDT References: <198@comp.lancs.ac.uk> <753@moscom.UUCP> Reply-To: leiby@masscomp.UUCP (Mike Leibensperger) Distribution: net Organization: Masscomp - Westford, Ma Lines: 22 Summary: How to do it using sh(1)... ref. K&P In article <753@moscom.UUCP> de@moscom.UUCP (Dave Esan) quotes someone else: >> >> I surrender -- is it possible to pass command line arguments to awk? >> >> If so - how. While I'm at it how about doing the same thing to sed. One way to do it is to put your awk command in a shell script, and play with shell quoting to put the shell arguments where you want them. This example, : awk '{ s += $'$1' } END { print s }' from _The_UNIX_Programming_Environment_ by Kernighan and Pike, shows the basic idea. -- Rt. Rev. Mike Leibensperger, Archbishop of Chelmsford Church of St. Clint the Righteous ("Feel lucky, Pink Boy?") Masscomp; 1 Technology Park; Westford, MA 01886 {decvax,ihnp4,tektronix}!masscomp!leiby