X-Spam-Check-By: sourceware.org
X-BigFish: V
X-MS-Exchange-Organization-Antispam-Report: OrigIP: 204.180.196.11;Service: EHS
Content-class: urn:content-classes:message
MIME-Version: 1.0
Content-Type: text/plain; 	charset="us-ascii"
Subject: RE:  Can I use a variable in sed?
Date: Fri, 25 May 2007 09:24:44 -0400
Message-ID: <CA77FC40E7A2D24695CF3C790BB73185CE9C3A@DOVMS10001.goss.gossinternational.com>
In-Reply-To: <f33jbo$cnq$1@sea.gmane.org>
From: "Long, Phillip GOSS" <Phillip.Long@gossinternational.com>
To: <cygwin@cygwin.com>
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
Precedence: bulk
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie.com@cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id l4PDOn4F018453

Jerome Fong wrote:
> I'm trying to write a script that allows me to change the port
> 	[snip]
> Here is the line I'm executing
> 
> sed '1,$ s^8080^$Shutdown_Port^' <./temp.xml >./server.xml
> 	[snip]
> What am I doing wrong here?  Can sed be passed a variable?
> 
> thanks,
> 
> Jerome
> 

Assuming that U're using bash, use double-quotes around the shell
variable; single-quotes escape the dollar-sign ($) for variables.
If U need to mix-and-match single- and double-quotes, adjacent
strings (no intervening whitespace) are automatically concatenated,
so this string:
   sed '1,$ s^8080^'"$Shutdown_Port"'^' ...
should fill the bill.
 
--------------------------------------------------------

Goss ... Innovation for Business

NOTICE: This e-mail and any attachment(s) may contain confidential and proprietary information of Goss International Corporation and/or its subsidiaries and may be legally privileged. This e-mail is intended solely for the addressee. If you are not the addressee, dissemination, copying or other use of this e-mail or any of its content is strictly prohibited and may be unlawful. If you are not the intended recipient please inform the sender immediately and destroy the e-mail and any copies. All liability for viruses is excluded to the fullest extent permitted by law. Any views expressed in this message are those of the individual sender. No contract may be construed by this e-mail.


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


