Re: No escape from the dollar sign in SED

"Daniel Goldman [email protected] [sed-users]" <[email protected]> Wed, 4 Apr 2018 09:06:55 -0700
Newsgroups gmane.editors.sed.user
Message-ID <[email protected]>
Or simply:

$ cat /tmp/script-1.sh
path=/mnt/stick
echo ftpdir=$path

$ /tmp/script-1.sh
ftpdir=/mnt/stick

Daniel

On 4/4/2018 6:18 AM, Tim Chase [email protected] [sed-users] wrote:
> On 2018-04-04 04:07, [email protected] [sed-users] wrote:
>> root@zero:~# usb='/mnt/stick'; echo 'Path $path is it!' | sed -r
>> 's|'\\$'path'"|$usb|g" Path /mnt/stick is it!
>
> It seems like you really would be better off using `envsubst`
> (available on all my linux & BSD boxes with anything that installed
> the GNU gettext package):
>
>    $ path='/mnt/stick'
>    $ echo "Path $path is it!" | envsubst
>    Path /mnt/stick is it!
>
> It's a lot cleaner and won't get hung up on things like paths that
> contain pipes or other odd characters.
>
> I'm not positive it's available in a busybox environment as I don't
> have one readily at hand.
>
> -tim
>
>
>
>
>
> ------------------------------------
> Posted by: Tim Chase <[email protected]>
> ------------------------------------
>


------------------------------------

------------------------------------

-- 

------------------------------------

Yahoo Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/sed-users/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/sed-users/join
    (Yahoo! ID required)

<*> To change settings via email:
    [email protected] 
    [email protected]

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo Groups is subject to:
    https://info.yahoo.com/legal/us/yahoo/utos/terms/