BB Unix Network Monitor - Message

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: {bb} {BB} OT: sed problem..



On Thu, 2006-01-19 at 15:56, Frank Timmers wrote:
> Hi brothers,
> 
> With all the script guru's here I thought maybe one of you might be able 
> to help out with a weird problem. I'm trying to escape the slashes in a 
> date so I can use it in another search and replace. however it dos work 
> from a normal command prompt, but not in a subshell:
> 
> noob$ echo $session
> 2006/23/12
> noob$ echo  $session | sed -e 's/\//\\\//g'
> 2006\/23\/12
> noob$ session_reg=`echo  $session | sed -e 's/\//\\\//g'`
> sed: Function s/\//\\//g cannot be parsed.
> 
> in the end I like to use ${session_reg} in the following line:
> cat backup.log | sed -e "s/${session_reg}/<A 
> href=\"${session_html}.html\">${session_reg}<\/a>/" > backup.html
> 
> 
> the ${session_html} is created with the following ilne (and works..):
> session_html=`echo $session | sed -e 's/\//_/g'`

For the sake of completeness, I should also probably say that in
this case (since this substitution is to escape the default
delimiter for a later sed command) you could also just use a
non-default one. A pipe character is often popular.

cat backup.log | sed -e "s|${session}|<A
href=\"${session_html}.html\">${session}</a>|" > backup.html

That should simplify things a little.

Cheers, Phil.



-- 
Let me assure you that to us here at First National, you're not
just a number. You're two numbers, a dash, three more numbers,
another dash and another number. (James Estes)

--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=
To unsubscribe from this list, or to subscribe to the bb-digest list
send e-mail to mailto:majordomo@bb4.com with unsubscribe bb -and/or-
subscribe bb-digest in the BODY of the message.


Home | Main Index | Thread Index