From owner-freebsd-stable Fri Sep 15 0:44:19 2000 Delivered-To: freebsd-stable@freebsd.org Received: from exchange.mistral.co.uk (gate.mistral.co.uk [195.184.225.3]) by hub.freebsd.org (Postfix) with ESMTP id 028C537B422 for ; Fri, 15 Sep 2000 00:44:14 -0700 (PDT) Received: from bizboz.mistral.co.uk ([195.184.225.25]) by exchange.mistral.co.uk with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2448.0) id SWW2RSAQ; Fri, 15 Sep 2000 08:35:37 +0100 Received: by bizboz.mistral.co.uk (Postfix, from userid 1000) id 2BB1838D; Fri, 15 Sep 2000 08:43:59 +0100 (BST) Date: Fri, 15 Sep 2000 08:43:58 +0100 From: Dominic Mitchell To: Gary Kline Cc: Gregory Bond , Randall Hopper , freebsd-stable@FreeBSD.ORG Subject: Re: "set -A" Bourne script - a nogo on FreeBSD Message-ID: <20000915084358.B77219@bizboz.mistral.co.uk> References: <200009150310.OAA26100@lightning.itga.com.au> <200009150325.e8F3Pns34741@thought.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2i In-Reply-To: <200009150325.e8F3Pns34741@thought.org>; from kline@thought.org on Thu, Sep 14, 2000 at 08:25:48PM -0700 X-Warning: Incoming message from The Big Giant Head! X-OS: FreeBSD 4.1-RC i386 X-Uptime: 8:18AM up 56 days, 15:53, 10 users, load averages: 1.26, 1.10, 1.20 Sender: owner-freebsd-stable@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Thu, Sep 14, 2000 at 08:25:48PM -0700, Gary Kline wrote: > I have a csh or sh question--sorry for asking it this way; > but is there any rational way of turning a file named > > foo.c to foo.o or simply foo with or without calling > non-builtin programs? I think I remember a sh wizard > showing me some bizarre sh command...but not sure it wasn't > a dream! $ fn=foo.c ; mv $fn ${fn%.c}.o (Ideally I wouldn't need that semicolon there, but it doesn't appear to work that way). Look for the string "%%" in sh(1). Generally, it's a way of of stripping the right hand side off of strings. Likewise, you can use "#" and "##" to strip off the left hand side of strings. For example, a minimal replacement for basename(1): $ me=/usr/local/bin/myscript $ echo ${me##*/} myscript Note that these mechanisms are derived from ksh, so are not available under every /bin/sh in the world, only really *BSD and Linux. -Dom To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-stable" in the body of the message