Re: [opensuse] Bash - sed variable help needed



Jon Clausen wrote:
On Sat, 16 Aug, 2008 at 02:14:03 -0500, David C. Rankin wrote:

What I want to do is something like:

for i in $(ls); do

ORIG_FNAME=$i
NEW_FNAME=$(echo $i | sed -e 's/^100/`date +%Y%m%d`/')

This is where the trouble comes in. I can't see a way to accomplish this. Anybody have any ideas? I guess I could turn the problem around and grab the numerical part on the right side of the _ with sed and then concatenate the date to that. However, if this is a way to work a variable into sed, that would be great. Any ideas?

Use double quotes instead;

... | sed -e "s/^100/$(date +%Y%m%d)/"

hth
/jon

Excellent! I knew it had to the simple. Thanks jon!

--
David C. Rankin, J.D., P.E.
Rankin Law Firm, PLLC
510 Ochiltree Street
Nacogdoches, Texas 75961
Telephone: (936) 715-9333
Facsimile: (936) 715-9339
www.rankinlawfirm.com
--
To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse+help@xxxxxxxxxxxx



Relevant Pages

  • Re: ADO.net Book
    ... > VB-dao programmer. ... I am having trouble trying to accomplish simple ... I am getting frustrated trying to accomplish simple tasks ... Maybe I should just stick with DAO? ...
    (microsoft.public.dotnet.framework.adonet)
  • parsing data
    ... I am having some trouble coming up with a solution for what I am ... trying to accomplish. ... Any advice is greatly appreciated. ... incorporated regex, but I am not real sure how to begin this task. ...
    (perl.beginners)
  • ADO.net Book
    ... programmer. ... also am having trouble accessing a specific field in the database. ... trying to accomplish simple tasks that I could do with DAO. ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Question about MSINET.OCX
    ... I have found that msinet.ocx is more trouble than it is worth. ... can use something else like Microsoft.XMLHTTP to accomplish what you are ... Prev by Date: ...
    (microsoft.public.dotnet.languages.vb)
  • Re: 545 wedge-style flasher bulbs
    ... wondering about how cheap/simple a circuit would be to just accomplish ... simple blinking... ... More trouble & space than it's worth. ...
    (rec.games.pinball)