🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: dc.org.linux-users
Article #3828

Re: general unix question (sed)

#3828
From: Mark Feit
Date: Tue, 11 Jul 1995 00:00
34 lines
1730 bytes
On dc.org.linux-users chazz@cais.com (Charles Meredith) posts:
 > 
 > indierok@clark.net (aka campbell) wrote:
 > 
 > >ok... i'm trying to do this from within a bash script... 
 > >first of all it works fine from the commmand line:
 > 
 > >OLD='Jun 9 15:57'
 > >NEW='Jul 9 10:10'
 > >sed s/"$OLD"/"$NEW"/g file >newfile  
 > 
 > 	   I'm not sure, but I think this should be:
 > 
 > 		sed s/\"$OLD\"/\"$NEW\"/g file >newfile
 > 
 > 	   Let me know if it works....

That would expand to

	sed s/"Jun 9 15:57"/"Jul 9 10:10"/g

which only gives you s/"Jun as the sed script (plus some garbage
leftover), which isn't what you want.  The shell will expand the
environment variables inside of the quotes around a *single*
string. which is what sed's expecting: sed -e "s/$OLD/$NEW/g".

						- Mark

 ................................... ...................................
: Mark A. Feit, KR4FH  mark@era.com :  Engineering Research Associates  :
: Software Engineer and Systems Guy :  Advanced Communications Division :
 ................................... ...................................
  "Rock journalism is people who can't write interviewing people who
  can't talk for people who can't read."  -- Frank Zappa, 1940-1993
Technical Details
Message-ID: <MARK.95Jul11090702@sam-i-am.era.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <3tq1pt$tp@clarknet.clark.net> <3tsebf$i8u@news.cais.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 11663c,20180fab603243c7
X-Google-Attributes: gid11663c,public
From: mark@ERA.COM (Mark Feit)
Subject: Re: general unix question (sed)
Date: 1995/07/11
Message-ID: <MARK.95Jul11090702@sam-i-am.era.com>
X-Deja-AN: 106054664
sender: news@ERA.COM
references: <3tq1pt$tp@clarknet.clark.net> <3tsebf$i8u@news.cais.com>
organization: Engineering Research Associates, Vienna, VA
newsgroups: dc.org.linux-users