Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  nodelist  faq  login

Maybe Computer Science should be in the College of Theology. -- R. S. Barton


rocksolid / Linux / Re: sed in FreeBSD

SubjectAuthor
* sed in FreeBSDRetro Guy
+- Re: sed in FreeBSDAnonymous
`- Re: sed in FreeBSDNeodome Admin

1
Subject: sed in FreeBSD
From: Retro Guy
Newsgroups: rocksolid.shared.linux
Organization: novaBBS
Date: Thu, 29 Oct 2020 08:58 UTC
Path: i2pn2.org!.POSTED!not-for-mail
From: retro....@rocksolidbbs.com (Retro Guy)
Newsgroups: rocksolid.shared.linux
Subject: sed in FreeBSD
Date: Thu, 29 Oct 2020 08:58:20 +0000
Organization: novaBBS
Message-ID: <df1dc31d8b278f059672082de3517c89$1@www.novabbs.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: i2pn2.org; posting-account="retrobbs1";
logging-data="8804"; mail-complaints-to="usenet@i2pn2.org"
User-Agent: Rocksolid Light (news.novabbs.com/getrslight)
X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on novabbs
X-Rslight-Site: $2y$10$1U7E3yvx3B5nDcydN3n6OOLg.9dNzxy9z.5.0tuvbiASOi1NY3StC
View all headers
Sorry, there's no bsd group so posting here :)

I needed to run sed to replace a bunch of stuff in a bunch of files, so I wrote this command:

sed -i "s/$somevariable/$MAGNET['somevariable']/g" $1

which does not work in FreeBSD. Error is 'Undefined variable', which I can understand, so I swapped around the quotes and end up with an error "Mismatched ''' ". They were not mismatched and I never did get it to work. I tried many different tweaks to the command, not always getting the same error, but always an error.

It works fine in Linux, so I ended up making the mods on a Debian box, then transferring back to FreeBSD (which worked fine). I'm curious if anyone can offer a sed command to do what's shown above that would work in FreeBSD. I'm sure it can be done just fine, but I tried and tried and finally gave up (for now), since I can do it in Linux.

And of course, after all that work, I just found the answer:

"the BSD build of sed mandates the extension for the backup file with -i, rather than it being optional, as in GNU sed"

So, this works in FreeBSD:

sed -i .bak 's/$somevariable/$MAGNET["somevariable"]/g' $1

There you have it. Answered my own question.

Retro Guy

--
Posted on: novaBBS
www.novabbs.com


Subject: Re: sed in FreeBSD
From: Anonymous
Newsgroups: rocksolid.shared.linux
Organization: i2pn2 (i2pn.org)
Date: Thu, 29 Oct 2020 09:14 UTC
References: 1
Path: i2pn2.org!.POSTED!not-for-mail
From: pos...@anon.com (Anonymous)
Newsgroups: rocksolid.shared.linux
Subject: Re: sed in FreeBSD
Date: Thu, 29 Oct 2020 02:14:21 -0700
Organization: i2pn2 (i2pn.org)
Message-ID: <l.713.3usni2@anon.com>
References: <df1dc31d8b278f059672082de3517c89$1@www.novabbs.com>
Content-Type: text/plain; charset=UTF-8
Injection-Info: i2pn2.org; posting-account="def2";
logging-data="11176"; mail-complaints-to="usenet@i2pn2.org"
View all headers
"the BSD build of sed mandates the extension for the backup file with -i, rather than it being optional, as in GNU sed"

this comes back to the question if you can/should protect a person from him/herself. GNU says no, BSD says yes....
the error messages seem to be kind of misleading though....

--
Posted on def2


Subject: Re: sed in FreeBSD
From: Neodome Admin
Newsgroups: rocksolid.shared.linux
Organization: Neodome
Date: Fri, 30 Oct 2020 16:09 UTC
References: 1
Path: i2pn2.org!i2pn.org!news.neodome.net!.POSTED!not-for-mail
From: adm...@neodome.net (Neodome Admin)
Newsgroups: rocksolid.shared.linux
Subject: Re: sed in FreeBSD
Date: Fri, 30 Oct 2020 16:09:42 -0000 (UTC)
Organization: Neodome
Message-ID: <rnhds6$j4i$1@neodome.net>
References: <df1dc31d8b278f059672082de3517c89$1@www.novabbs.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 30 Oct 2020 16:09:42 -0000 (UTC)
Injection-Info: neodome.net; mail-complaints-to="abuse@neodome.net"
User-Agent: NewsTap/5.4.1 (iPhone/iPod Touch)
Cancel-Lock: sha1:XtAGW0WATkLjNbVJr7R1nIsiF2E=
View all headers
Retro Guy <retro.guy@rocksolidbbs.com> wrote:
Sorry, there's no bsd group so posting here :)

There are comp.unix.bsd.freebsd.misc (very low traffic) and comp.unix.shell
(still pretty much alive.)

--
Neodome


1
rocksolid light 0.7.2
clearneti2ptor