From owner-freebsd-questions Wed Mar 12 2:10:33 2003 Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id F098837B401 for ; Wed, 12 Mar 2003 02:10:31 -0800 (PST) Received: from mailhost.stack.nl (vaak.stack.nl [131.155.140.140]) by mx1.FreeBSD.org (Postfix) with ESMTP id 29E8843F3F for ; Wed, 12 Mar 2003 02:10:31 -0800 (PST) (envelope-from dean@dragon.stack.nl) Received: by mailhost.stack.nl (Postfix, from userid 65534) id 02D8E1F0FD; Wed, 12 Mar 2003 11:10:29 +0100 (CET) Received: from dragon.stack.nl (dragon.stack.nl [2001:610:1108:5011:207:e9ff:fe09:230]) by mailhost.stack.nl (Postfix) with ESMTP id 5AC1C1F0FB; Wed, 12 Mar 2003 11:10:29 +0100 (CET) Received: by dragon.stack.nl (Postfix, from userid 1600) id 48DCB5F174; Wed, 12 Mar 2003 11:10:29 +0100 (CET) Date: Wed, 12 Mar 2003 11:10:29 +0100 From: Dean Strik To: Kok Kok Cc: freebsd-questions@FreeBSD.ORG Subject: Re: sed to replace the words Message-ID: <20030312101029.GB27853@dragon.stack.nl> References: <20030312061655.26510.qmail@web13305.mail.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20030312061655.26510.qmail@web13305.mail.yahoo.com> X-Editor: VIM Rulez! http://www.vim.org/ X-MUD: Outerspace - telnet://mud.stack.nl:3333 X-Really: Yes User-Agent: Mutt/1.5.3i X-Spam-Status: No, hits=-2.5 required=8.0 tests=IN_REP_TO,REFERENCES,SIGNATURE_SHORT_DENSE, SPAM_PHRASE_00_01,USER_AGENT,USER_AGENT_MUTT version=2.43 X-Spam-Level: Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Kok Kok wrote: > Hi all > > I have question how to replace words using sed > > ./script 61.100 192.168 > > The script is > #!/bin/sh > sed -e 's/$2/$1/g' file > newfile > > The problem is 192.168 can't replace 61.100 in the > newfile The single quotes prevent interpolation, the $... are not treated as variables by the shell. Use double quotes instead: sed -e "s/$2/$1/g" file > newfile -- Dean C. Strik Eindhoven University of Technology dean@stack.nl | dean@ipnet6.org | http://www.ipnet6.org/ "This isn't right. This isn't even wrong." -- Wolfgang Pauli To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message