From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2999 invoked by alias); 21 May 2012 19:49:10 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 17098 Received: (qmail 8949 invoked from network); 21 May 2012 19:49:07 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 Received-SPF: none (ns1.primenet.com.au: domain at closedmail.com does not designate permitted sender hosts) From: Bart Schaefer Message-id: <120521124847.ZM331@torch.brasslantern.com> Date: Mon, 21 May 2012 12:48:47 -0700 In-reply-to: <20120518143025.7d525f91@pwslap01u.europe.root.pri> Comments: In reply to Peter Stephenson "Re: Extracting the 4th word of the first line in a file - is there a more elegant solution?" (May 18, 2:30pm) References: <1337347014.26363.140661077285713.26DAE636@webmail.messagingengine.com> <20120518143025.7d525f91@pwslap01u.europe.root.pri> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: Subject: Re: Extracting the 4th word of the first line in a file - is there a more elegant solution? MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On May 18, 2:30pm, Peter Stephenson wrote: } } You can do it without an auxiliary process, but with a local variable, } which is probably more efficient and the best compromise: } } read -A line <$1 } field=$line[4] If you're already using a local throwaway, read x x x field x <$1 Or you can use the omnipresent local argv so you needn't declare it: (){ read -A argv; field=$4 } < $1 } You might want "read -qe" if the file contains backslashes. I believe -q is a typo for -r there.