Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!ucla-cs!zen!ucbvax!cartan!brahms.Berkeley.EDU!ballou From: ballou@brahms.Berkeley.EDU.UUCP Newsgroups: comp.unix.questions Subject: Re: executable awk scripts Message-ID: <1236@cartan.Berkeley.EDU> Date: Thu, 17-Sep-87 18:40:17 EDT Article-I.D.: cartan.1236 Posted: Thu Sep 17 18:40:17 1987 Date-Received: Sat, 19-Sep-87 10:12:36 EDT References: <1881@vax135.UUCP> Sender: nobody@cartan.Berkeley.EDU Reply-To: ballou@brahms.Berkeley.EDU.UUCP (Kenneth R. Ballou) Distribution: na Organization: Math Dept. UCB Lines: 39 In article <1881@vax135.UUCP> whb@vax135.UUCP (Wilson H. Bent) writes: >[ The line-eater lives! Probably because people keep feeding it...] > >Given that these files are executable, why does this fail: > > #!/bin/awk > { print $1 } > >when this works: > > #!/bin/sh > /bin/awk '{ print $1 }' > The semantics of '#!' are as follows. A command line is constructed by taking the text immediately following the #! (up to some limit which, I believe, is 30 characters), appending a space, then copying the command line which invoked the shell script. So, assuming in both cases the shell script file name is 'foo', the first case behaves as: /bin/awk foo while the second case behaves as: /bin/sh /bin/awk '{ print $1 }' In the second case, the shell forks a process with command line /bin/awk '{ print $1 }' The first case leaves awk with no program (since a file containing a program must be specified as -f filename). -------- Kenneth R. Ballou ARPA: ballou@brahms.berkeley.edu Department of Mathematics UUCP: ...!ucbvax!brahms!ballou University of California