Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

The only way to learn a new programming language is by writing programs in it. -- Brian Kernighan


devel / comp.unix.shell / sed replace strings with single quotes and brackets

SubjectAuthor
* sed replace strings with single quotes and bracketsHarry
`* Re: sed replace strings with single quotes and bracketsDavid W. Hodgins
 `* Re: sed replace strings with single quotes and bracketsHarry
  `* Re: sed replace strings with single quotes and bracketsapplemcg
   `* Re: sed replace strings with single quotes and bracketsJanis Papanagnou
    `* Re: sed replace strings with single quotes and bracketsapplemcg
     `* Re: sed replace strings with single quotes and bracketsJanis Papanagnou
      `* Re: sed replace strings with single quotes and bracketsStonebridge Mens Club
       +- Re: sed replace strings with single quotes and bracketsJanis Papanagnou
       +* Re: sed replace strings with single quotes and bracketsKeith Thompson
       |`- Re: sed replace strings with single quotes and bracketsLew Pitcher
       `- Re: sed replace strings with single quotes and bracketsKaz Kylheku

1
sed replace strings with single quotes and brackets

<7f0984fc-878e-4b5d-bd21-54b2e2fab500n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4597&group=comp.unix.shell#4597

  copy link   Newsgroups: comp.unix.shell
X-Received: by 2002:a05:620a:4088:: with SMTP id f8mr8617437qko.418.1636491582357;
Tue, 09 Nov 2021 12:59:42 -0800 (PST)
X-Received: by 2002:ac8:7f09:: with SMTP id f9mr6778024qtk.133.1636491582223;
Tue, 09 Nov 2021 12:59:42 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.unix.shell
Date: Tue, 9 Nov 2021 12:59:42 -0800 (PST)
Injection-Info: google-groups.googlegroups.com; posting-host=96.49.148.18; posting-account=0cwH1wkAAACyHC8RuqgGpRum9kOwb46T
NNTP-Posting-Host: 96.49.148.18
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <7f0984fc-878e-4b5d-bd21-54b2e2fab500n@googlegroups.com>
Subject: sed replace strings with single quotes and brackets
From: harryooo...@hotmail.com (Harry)
Injection-Date: Tue, 09 Nov 2021 20:59:42 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Harry - Tue, 9 Nov 2021 20:59 UTC

I am trying to modify a whole bunch of text files (*.sh)
with a small shell script.

$ cat yy
SRC="new_time(tx.create_dt_tm,'GMT','TIMEZONE')"
DEST="cast(from_tz(cast(tx.create_dt_tm as timestamp), 'Etc/GMT0') at time zone 'Canada/Pacific' as date)"
for i in *.sh
do
echo modifying $i ...
sed -i "s/$SRC/$DEST/g" $i
done

I got errors like these ... what am I missing ?

modifying xxx.sh ...
sed: -e expression #1, char 100: unknown option to `s'

Note: both $SRC and $DEST have no double quotes in the string contents.

TIA

Re: sed replace strings with single quotes and brackets

<op.1clzyaoza3w0dxdave@hodgins.homeip.net>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4598&group=comp.unix.shell#4598

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: dwhodg...@nomail.afraid.org (David W. Hodgins)
Newsgroups: comp.unix.shell
Subject: Re: sed replace strings with single quotes and brackets
Date: Tue, 09 Nov 2021 16:14:24 -0500
Organization: A noiseless patient Spider
Lines: 35
Message-ID: <op.1clzyaoza3w0dxdave@hodgins.homeip.net>
References: <7f0984fc-878e-4b5d-bd21-54b2e2fab500n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes
Content-Transfer-Encoding: 8bit
Injection-Info: reader02.eternal-september.org; posting-host="e6a39b9c3877df37528115112ac4d0fb";
logging-data="19676"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/kG3X5911keCrF9zMI+//L5APqnPxDYkU="
User-Agent: Opera Mail/12.16 (Linux)
Cancel-Lock: sha1:0Co94KOCZYCMjOqXWNIROSP1aKc=
 by: David W. Hodgins - Tue, 9 Nov 2021 21:14 UTC

On Tue, 09 Nov 2021 15:59:42 -0500, Harry <harryooopotter@hotmail.com> wrote:

> I am trying to modify a whole bunch of text files (*.sh)
> with a small shell script.
>
> $ cat yy
> SRC="new_time(tx.create_dt_tm,'GMT','TIMEZONE')"
> DEST="cast(from_tz(cast(tx.create_dt_tm as timestamp), 'Etc/GMT0') at time zone 'Canada/Pacific' as date)"
> for i in *.sh
> do
> echo modifying $i ...
> sed -i "s/$SRC/$DEST/g" $i
> done
>
> I got errors like these ... what am I missing ?
>
> modifying xxx.sh ...
> sed: -e expression #1, char 100: unknown option to `s'
>
> Note: both $SRC and $DEST have no double quotes in the string contents.

Run it with "bash -x -v yy"

+ for i in *.sh
+ echo modifying newcerts.sh ...
modifying newcerts.sh ...
+ echo sed -i 's/new_time(tx.create_dt_tm,'\''GMT'\'','\''TIMEZONE'\'')/cast(from_tz(cast(tx.create_dt_tm as timestamp), '\''Etc/GMT0'\'') at time zone '\''Canada/Pacific'\'' as date)/g' newcerts.sh
sed -i s/new_time(tx.create_dt_tm,'GMT','TIMEZONE')/cast(from_tz(cast(tx.create_dt_tm as timestamp), 'Etc/GMT0') at time zone 'Canada/Pacific' as date)/g newcerts.sh

Notice how the generated sed command contains too many slash characters.

Replace the delimiter slash characters with some other character not present in the
strings.

Regards, Dave Hodgins

Re: sed replace strings with single quotes and brackets

<f991a9d6-c9d1-4999-bad2-16c4ae44c2ccn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4599&group=comp.unix.shell#4599

  copy link   Newsgroups: comp.unix.shell
X-Received: by 2002:a05:620a:1a85:: with SMTP id bl5mr8569292qkb.200.1636496725750;
Tue, 09 Nov 2021 14:25:25 -0800 (PST)
X-Received: by 2002:a05:622a:1208:: with SMTP id y8mr12665142qtx.214.1636496725593;
Tue, 09 Nov 2021 14:25:25 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.unix.shell
Date: Tue, 9 Nov 2021 14:25:25 -0800 (PST)
In-Reply-To: <op.1clzyaoza3w0dxdave@hodgins.homeip.net>
Injection-Info: google-groups.googlegroups.com; posting-host=96.49.148.18; posting-account=0cwH1wkAAACyHC8RuqgGpRum9kOwb46T
NNTP-Posting-Host: 96.49.148.18
References: <7f0984fc-878e-4b5d-bd21-54b2e2fab500n@googlegroups.com> <op.1clzyaoza3w0dxdave@hodgins.homeip.net>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <f991a9d6-c9d1-4999-bad2-16c4ae44c2ccn@googlegroups.com>
Subject: Re: sed replace strings with single quotes and brackets
From: harryooo...@hotmail.com (Harry)
Injection-Date: Tue, 09 Nov 2021 22:25:25 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Harry - Tue, 9 Nov 2021 22:25 UTC

On Tuesday, November 9, 2021 at 1:14:37 PM UTC-8, David W. Hodgins wrote:

> Run it with "bash -x -v yy"
>
> + for i in *.sh
> + echo modifying newcerts.sh ...
> modifying newcerts.sh ...
> + echo sed -i 's/new_time(tx.create_dt_tm,'\''GMT'\'','\''TIMEZONE'\'')/cast(from_tz(cast(tx.create_dt_tm as timestamp), '\''Etc/GMT0'\'') at time zone '\''Canada/Pacific'\'' as date)/g' newcerts.sh
> sed -i s/new_time(tx.create_dt_tm,'GMT','TIMEZONE')/cast(from_tz(cast(tx.create_dt_tm as timestamp), 'Etc/GMT0') at time zone 'Canada/Pacific' as date)/g newcerts.sh
>
> Notice how the generated sed command contains too many slash characters.
>
> Replace the delimiter slash characters with some other character not present in the
> strings.

Thanks, I replace / with # in the sed cmd and it works now.

Re: sed replace strings with single quotes and brackets

<37e18c8c-e190-494c-973f-f5f79b919d11n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4600&group=comp.unix.shell#4600

  copy link   Newsgroups: comp.unix.shell
X-Received: by 2002:a05:622a:15c5:: with SMTP id d5mr18443262qty.227.1636817726935;
Sat, 13 Nov 2021 07:35:26 -0800 (PST)
X-Received: by 2002:a05:6214:2429:: with SMTP id gy9mr22883882qvb.36.1636817726671;
Sat, 13 Nov 2021 07:35:26 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.unix.shell
Date: Sat, 13 Nov 2021 07:35:26 -0800 (PST)
In-Reply-To: <f991a9d6-c9d1-4999-bad2-16c4ae44c2ccn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=173.71.87.95; posting-account=cdsHlAoAAAChJwblggpJABTs6mDsS965
NNTP-Posting-Host: 173.71.87.95
References: <7f0984fc-878e-4b5d-bd21-54b2e2fab500n@googlegroups.com>
<op.1clzyaoza3w0dxdave@hodgins.homeip.net> <f991a9d6-c9d1-4999-bad2-16c4ae44c2ccn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <37e18c8c-e190-494c-973f-f5f79b919d11n@googlegroups.com>
Subject: Re: sed replace strings with single quotes and brackets
From: marty.mc...@gmail.com (applemcg)
Injection-Date: Sat, 13 Nov 2021 15:35:26 +0000
Content-Type: text/plain; charset="UTF-8"
 by: applemcg - Sat, 13 Nov 2021 15:35 UTC

On Tuesday, November 9, 2021 at 5:25:28 PM UTC-5, Harry wrote:
> On Tuesday, November 9, 2021 at 1:14:37 PM UTC-8, David W. Hodgins wrote:
>
> > Run it with "bash -x -v yy"
> >
> > + for i in *.sh
> > + echo modifying newcerts.sh ...
> > modifying newcerts.sh ...
> > + echo sed -i 's/new_time(tx.create_dt_tm,'\''GMT'\'','\''TIMEZONE'\'')/cast(from_tz(cast(tx.create_dt_tm as timestamp), '\''Etc/GMT0'\'') at time zone '\''Canada/Pacific'\'' as date)/g' newcerts.sh
> > sed -i s/new_time(tx.create_dt_tm,'GMT','TIMEZONE')/cast(from_tz(cast(tx.create_dt_tm as timestamp), 'Etc/GMT0') at time zone 'Canada/Pacific' as date)/g newcerts.sh
> >
> > Notice how the generated sed command contains too many slash characters.
> >
> > Replace the delimiter slash characters with some other character not present in the
> > strings.
> Thanks, I replace / with # in the sed cmd and it works now.

anytime there's a potential file path involved mine looks like

sed "s=$this=$that="

suggesting a function:

psed () { : path-protected sed; sed "s=$1=$2=g" ; }

Re: sed replace strings with single quotes and brackets

<smoq7m$j0q$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4601&group=comp.unix.shell#4601

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: sed replace strings with single quotes and brackets
Date: Sat, 13 Nov 2021 17:47:49 +0100
Organization: A noiseless patient Spider
Lines: 30
Message-ID: <smoq7m$j0q$1@dont-email.me>
References: <7f0984fc-878e-4b5d-bd21-54b2e2fab500n@googlegroups.com>
<op.1clzyaoza3w0dxdave@hodgins.homeip.net>
<f991a9d6-c9d1-4999-bad2-16c4ae44c2ccn@googlegroups.com>
<37e18c8c-e190-494c-973f-f5f79b919d11n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 13 Nov 2021 16:47:50 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="5c0ff887abf4589d5171243693f13aab";
logging-data="19482"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/5AxOGaS3APR07kxwcCdob"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:liDeLLn+Ueq1Ym5qu3yO28qoN8Y=
In-Reply-To: <37e18c8c-e190-494c-973f-f5f79b919d11n@googlegroups.com>
X-Enigmail-Draft-Status: N1110
 by: Janis Papanagnou - Sat, 13 Nov 2021 16:47 UTC

On 13.11.2021 16:35, applemcg wrote:
> On Tuesday, November 9, 2021 at 5:25:28 PM UTC-5, Harry wrote:
>> On Tuesday, November 9, 2021 at 1:14:37 PM UTC-8, David W. Hodgins wrote:
>>> [ slash characters in sed substitution and as sed separators ]
>>> Notice how the generated sed command contains too many slash characters.
>>>
>>> Replace the delimiter slash characters with some other character not present in the
>>> strings.
>> Thanks, I replace / with # in the sed cmd and it works now.
>
>
> anytime there's a potential file path involved mine looks like
>
> sed "s=$this=$that="
>
> suggesting a function:
>
> psed () { : path-protected sed; sed "s=$1=$2=g" ; }
>

Functions should be suggested if they are generally applicable.
Your code shows the same issue with '=' characters that the OP
had with '/' characters. (Consider path-component data with '='
and $this or $that containing a '='.)

Taking another rare character might delay the failure further but
not solve the task generally.

Janis

Re: sed replace strings with single quotes and brackets

<45014fa1-3f51-4b3f-a384-77b1b1a97a16n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4602&group=comp.unix.shell#4602

  copy link   Newsgroups: comp.unix.shell
X-Received: by 2002:a05:6214:27c7:: with SMTP id ge7mr23701929qvb.44.1636823969564;
Sat, 13 Nov 2021 09:19:29 -0800 (PST)
X-Received: by 2002:a05:620a:bd5:: with SMTP id s21mr19579793qki.175.1636823969284;
Sat, 13 Nov 2021 09:19:29 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.unix.shell
Date: Sat, 13 Nov 2021 09:19:29 -0800 (PST)
In-Reply-To: <smoq7m$j0q$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=173.71.87.95; posting-account=cdsHlAoAAAChJwblggpJABTs6mDsS965
NNTP-Posting-Host: 173.71.87.95
References: <7f0984fc-878e-4b5d-bd21-54b2e2fab500n@googlegroups.com>
<op.1clzyaoza3w0dxdave@hodgins.homeip.net> <f991a9d6-c9d1-4999-bad2-16c4ae44c2ccn@googlegroups.com>
<37e18c8c-e190-494c-973f-f5f79b919d11n@googlegroups.com> <smoq7m$j0q$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <45014fa1-3f51-4b3f-a384-77b1b1a97a16n@googlegroups.com>
Subject: Re: sed replace strings with single quotes and brackets
From: marty.mc...@gmail.com (applemcg)
Injection-Date: Sat, 13 Nov 2021 17:19:29 +0000
Content-Type: text/plain; charset="UTF-8"
 by: applemcg - Sat, 13 Nov 2021 17:19 UTC

On Saturday, November 13, 2021 at 11:47:55 AM UTC-5, Janis Papanagnou wrote:
> On 13.11.2021 16:35, applemcg wrote:
> > On Tuesday, November 9, 2021 at 5:25:28 PM UTC-5, Harry wrote:
> >> On Tuesday, November 9, 2021 at 1:14:37 PM UTC-8, David W. Hodgins wrote:
> >>> [ slash characters in sed substitution and as sed separators ]
> >>> Notice how the generated sed command contains too many slash characters.
> >>>
> >>> Replace the delimiter slash characters with some other character not present in the
> >>> strings.
> >> Thanks, I replace / with # in the sed cmd and it works now.
> >
> >
> > anytime there's a potential file path involved mine looks like
> >
> > sed "s=$this=$that="
> >
> > suggesting a function:
> >
> > psed () { : path-protected sed; sed "s=$1=$2=g" ; }
> >
> Functions should be suggested if they are generally applicable.
> Your code shows the same issue with '=' characters that the OP
> had with '/' characters. (Consider path-component data with '='
> and $this or $that containing a '='.)
>
> Taking another rare character might delay the failure further but
> not solve the task generally.
>
> Janis

of course; one might defend oneself against a range of unlikely characters
using a CASE statement.

my last gainful employ was as trainer at a wall st fin svcs company. our
help desk, operating on Windows, trying to read log files with date stamps in their
name were relieved to see a file system where the HH:MM:SS's were linked with LN(1),
to an HH_MM_SS named file sometimes the fix lies elsewhere.

Re: sed replace strings with single quotes and brackets

<smouo4$j7e$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4603&group=comp.unix.shell#4603

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: sed replace strings with single quotes and brackets
Date: Sat, 13 Nov 2021 19:04:52 +0100
Organization: A noiseless patient Spider
Lines: 21
Message-ID: <smouo4$j7e$1@dont-email.me>
References: <7f0984fc-878e-4b5d-bd21-54b2e2fab500n@googlegroups.com>
<op.1clzyaoza3w0dxdave@hodgins.homeip.net>
<f991a9d6-c9d1-4999-bad2-16c4ae44c2ccn@googlegroups.com>
<37e18c8c-e190-494c-973f-f5f79b919d11n@googlegroups.com>
<smoq7m$j0q$1@dont-email.me>
<45014fa1-3f51-4b3f-a384-77b1b1a97a16n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 13 Nov 2021 18:04:52 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="5c0ff887abf4589d5171243693f13aab";
logging-data="19694"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19SgdzUAdNeKWJXi9Z1s/1K"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:Qmr+sn4HUfaO51YTBMUUwFiZCG0=
In-Reply-To: <45014fa1-3f51-4b3f-a384-77b1b1a97a16n@googlegroups.com>
X-Enigmail-Draft-Status: N1110
 by: Janis Papanagnou - Sat, 13 Nov 2021 18:04 UTC

On 13.11.2021 18:19, applemcg wrote:
>>>>> [ slash characters in sed substitution and as sed separators ]
>>
>> Taking another rare character might delay the failure further but
>> not solve the task generally.
>
> of course; one might defend oneself against a range of unlikely characters
> using a CASE statement.

Or dynamically checking the $this and $that values in the function.
Even using binary separator values might fail in pathological cases,
though using something like sed s$'\1'"$this"$'\1'"$that"$'\1'
certainly fails much rarer.

>
> my last gainful employ was as trainer at a wall st fin svcs company. [...]

(I cannot decipher "st fin svcs". - Ah, wait! Now I've got it.)

Janis

Re: sed replace strings with single quotes and brackets

<a54c0d04-6a9e-4a0e-9226-560c4ef6bd4en@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4604&group=comp.unix.shell#4604

  copy link   Newsgroups: comp.unix.shell
X-Received: by 2002:a05:620a:f8b:: with SMTP id b11mr31340146qkn.81.1636990765073;
Mon, 15 Nov 2021 07:39:25 -0800 (PST)
X-Received: by 2002:a37:de15:: with SMTP id h21mr19482476qkj.332.1636990764905;
Mon, 15 Nov 2021 07:39:24 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.uzoreto.com!feeder1.cambriumusenet.nl!feed.tweak.nl!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.unix.shell
Date: Mon, 15 Nov 2021 07:39:24 -0800 (PST)
In-Reply-To: <smouo4$j7e$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=173.71.87.95; posting-account=3YmjYQoAAABGLInVMFSouR4Hq2bXxB55
NNTP-Posting-Host: 173.71.87.95
References: <7f0984fc-878e-4b5d-bd21-54b2e2fab500n@googlegroups.com>
<op.1clzyaoza3w0dxdave@hodgins.homeip.net> <f991a9d6-c9d1-4999-bad2-16c4ae44c2ccn@googlegroups.com>
<37e18c8c-e190-494c-973f-f5f79b919d11n@googlegroups.com> <smoq7m$j0q$1@dont-email.me>
<45014fa1-3f51-4b3f-a384-77b1b1a97a16n@googlegroups.com> <smouo4$j7e$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <a54c0d04-6a9e-4a0e-9226-560c4ef6bd4en@googlegroups.com>
Subject: Re: sed replace strings with single quotes and brackets
From: sbmc08...@gmail.com (Stonebridge Mens Club)
Injection-Date: Mon, 15 Nov 2021 15:39:25 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Stonebridge Mens Clu - Mon, 15 Nov 2021 15:39 UTC

On Saturday, November 13, 2021 at 1:04:57 PM UTC-5, Janis Papanagnou wrote:
> On 13.11.2021 18:19, applemcg wrote:
> >>>>> [ slash characters in sed substitution and as sed separators ]
> >>
> >> Taking another rare character might delay the failure further but
> >> not solve the task generally.
> >
> > of course; one might defend oneself against a range of unlikely characters
> > using a CASE statement.
> Or dynamically checking the $this and $that values in the function.
> Even using binary separator values might fail in pathological cases,
> though using something like sed s$'\1'"$this"$'\1'"$that"$'\1'
> certainly fails much rarer.
>
> >
> > my last gainful employ was as trainer at a wall st fin svcs company. [...]
>
> (I cannot decipher "st fin svcs". - Ah, wait! Now I've got it.)
>
> Janis

Janis,

If I may, I'll disagree slightly with the idea that "Functions should
be suggested if they are generally applicable"

You have noticed a practice of mine: precede a command name with a
single letter to isolate a specific use of an idea, in this case psed.

I've a small family of awk wrappers: cawk, pawk, and tawk. a clue to
their usage:

tawk () { awk -F'\t' "$@"; }

"pawk" got quite a bit of use when i was at the T (at&~), since
pipe-separated tables were widely in use there.

"cawk" _never_ gets used. There seems to be no standard for the CSV
file. i.e. what if a field has a comma in it?

"tawk" has no such problems. there will never be a TAB in data field.
IBM saw to that with the 3270 terminal, since the TAB character (on
that machine) was designed to take the user to the next data input
field. And ...

I met Rod Manis, one of three authors of "Unix Relational Data Base
Management", which produced the text-only data base management system
/rdb. He gave me a draft of their book, ~ '86, and I produced a KSH
version. Where awk is the engine. Manis was dogmatic about little:

"There will never be a TAB character in a data field"

I'm at last producing a bash version -- annotated -- since a great
deal of the book is either obsolescent or application-specific, with
too much to do with accounting.

Re: sed replace strings with single quotes and brackets

<smu2r2$pm9$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4605&group=comp.unix.shell#4605

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: sed replace strings with single quotes and brackets
Date: Mon, 15 Nov 2021 17:45:22 +0100
Organization: A noiseless patient Spider
Lines: 11
Message-ID: <smu2r2$pm9$1@dont-email.me>
References: <7f0984fc-878e-4b5d-bd21-54b2e2fab500n@googlegroups.com>
<op.1clzyaoza3w0dxdave@hodgins.homeip.net>
<f991a9d6-c9d1-4999-bad2-16c4ae44c2ccn@googlegroups.com>
<37e18c8c-e190-494c-973f-f5f79b919d11n@googlegroups.com>
<smoq7m$j0q$1@dont-email.me>
<45014fa1-3f51-4b3f-a384-77b1b1a97a16n@googlegroups.com>
<smouo4$j7e$1@dont-email.me>
<a54c0d04-6a9e-4a0e-9226-560c4ef6bd4en@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 15 Nov 2021 16:45:22 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="54fc789eaeede4e973631ee1b1c4debf";
logging-data="26313"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+W3tRG80bh80axBKT2dV6q"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:LZMGrJ8K3ad3+lQW98yw98WWXA8=
In-Reply-To: <a54c0d04-6a9e-4a0e-9226-560c4ef6bd4en@googlegroups.com>
X-Enigmail-Draft-Status: N1110
 by: Janis Papanagnou - Mon, 15 Nov 2021 16:45 UTC

On 15.11.2021 16:39, Stonebridge Mens Club wrote:
>
> If I may, I'll disagree slightly with the idea that "Functions should
> be suggested if they are generally applicable"

The point in this thread was that the function was written to solve a
task but did that in an inherently error prone way. Please read this
statement in that context.

Janis

Re: sed replace strings with single quotes and brackets

<87tugduqcb.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4606&group=comp.unix.shell#4606

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.unix.shell
Subject: Re: sed replace strings with single quotes and brackets
Date: Mon, 15 Nov 2021 12:16:36 -0800
Organization: None to speak of
Lines: 16
Message-ID: <87tugduqcb.fsf@nosuchdomain.example.com>
References: <7f0984fc-878e-4b5d-bd21-54b2e2fab500n@googlegroups.com>
<op.1clzyaoza3w0dxdave@hodgins.homeip.net>
<f991a9d6-c9d1-4999-bad2-16c4ae44c2ccn@googlegroups.com>
<37e18c8c-e190-494c-973f-f5f79b919d11n@googlegroups.com>
<smoq7m$j0q$1@dont-email.me>
<45014fa1-3f51-4b3f-a384-77b1b1a97a16n@googlegroups.com>
<smouo4$j7e$1@dont-email.me>
<a54c0d04-6a9e-4a0e-9226-560c4ef6bd4en@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="4dfa4696cc9102eb97f9c6d39308d454";
logging-data="28961"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+EbFc+pyG2gSj5NYjzwisd"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:M2lR7frYkIBKfjEcdgWi52VDgWs=
sha1:R9T5aVcBDRptgzV91IQsoKwLx6U=
 by: Keith Thompson - Mon, 15 Nov 2021 20:16 UTC

Stonebridge Mens Club <sbmc08831@gmail.com> writes:
[...]
> "cawk" _never_ gets used. There seems to be no standard for the CSV
> file. i.e. what if a field has a comma in it?

As I recall there are multiple standards for CSV files.

The most nearly definitive is probably RFC 4180.

https://www.ietf.org/rfc/rfc4180.txt
https://datatracker.ietf.org/doc/html/rfc4180

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips
void Void(void) { Void(); } /* The recursive call of the void */

Re: sed replace strings with single quotes and brackets

<smug3s$1p3$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4607&group=comp.unix.shell#4607

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: lew.pitc...@digitalfreehold.ca (Lew Pitcher)
Newsgroups: comp.unix.shell
Subject: Re: sed replace strings with single quotes and brackets
Date: Mon, 15 Nov 2021 20:31:56 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 25
Message-ID: <smug3s$1p3$1@dont-email.me>
References: <7f0984fc-878e-4b5d-bd21-54b2e2fab500n@googlegroups.com>
<op.1clzyaoza3w0dxdave@hodgins.homeip.net>
<f991a9d6-c9d1-4999-bad2-16c4ae44c2ccn@googlegroups.com>
<37e18c8c-e190-494c-973f-f5f79b919d11n@googlegroups.com>
<smoq7m$j0q$1@dont-email.me>
<45014fa1-3f51-4b3f-a384-77b1b1a97a16n@googlegroups.com>
<smouo4$j7e$1@dont-email.me>
<a54c0d04-6a9e-4a0e-9226-560c4ef6bd4en@googlegroups.com>
<87tugduqcb.fsf@nosuchdomain.example.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 15 Nov 2021 20:31:56 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="0368a7a7089556eff0e6407199414589";
logging-data="1827"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1981zDX/5MC8RoYSUg58N8OpCEGC0Kc58s="
User-Agent: Pan/0.139 (Sexual Chocolate; GIT bf56508
git://git.gnome.org/pan2)
Cancel-Lock: sha1:mZzZc+wGOceu1N0J/fR2g5bUz+8=
 by: Lew Pitcher - Mon, 15 Nov 2021 20:31 UTC

On Mon, 15 Nov 2021 12:16:36 -0800, Keith Thompson wrote:

> Stonebridge Mens Club <sbmc08831@gmail.com> writes: [...]
>> "cawk" _never_ gets used. There seems to be no standard for the CSV
>> file. i.e. what if a field has a comma in it?
>
> As I recall there are multiple standards for CSV files.
>
> The most nearly definitive is probably RFC 4180.
>
> https://www.ietf.org/rfc/rfc4180.txt
> https://datatracker.ietf.org/doc/html/rfc4180

Caveat from https://www.ietf.org/rfc/rfc4180.txt:

Status of This Memo

This memo provides information for the Internet community. It does
not specify an Internet standard of any kind. Distribution of this
memo is unlimited.

--
Lew Pitcher
"In Skills, We Trust"

Re: sed replace strings with single quotes and brackets

<20211115144534.281@kylheku.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4608&group=comp.unix.shell#4608

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: 480-992-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.unix.shell
Subject: Re: sed replace strings with single quotes and brackets
Date: Mon, 15 Nov 2021 22:47:50 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 15
Message-ID: <20211115144534.281@kylheku.com>
References: <7f0984fc-878e-4b5d-bd21-54b2e2fab500n@googlegroups.com>
<op.1clzyaoza3w0dxdave@hodgins.homeip.net>
<f991a9d6-c9d1-4999-bad2-16c4ae44c2ccn@googlegroups.com>
<37e18c8c-e190-494c-973f-f5f79b919d11n@googlegroups.com>
<smoq7m$j0q$1@dont-email.me>
<45014fa1-3f51-4b3f-a384-77b1b1a97a16n@googlegroups.com>
<smouo4$j7e$1@dont-email.me>
<a54c0d04-6a9e-4a0e-9226-560c4ef6bd4en@googlegroups.com>
Injection-Date: Mon, 15 Nov 2021 22:47:50 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="240ebd33f1c9dffca8aed6c22ca2bd03";
logging-data="28404"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1++uszJg7W0UfyxxY2muLb0HGEpHEfrBuM="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:PdeeHcFuEYOpKqIuWqsvdzsGQs4=
 by: Kaz Kylheku - Mon, 15 Nov 2021 22:47 UTC

On 2021-11-15, Stonebridge Mens Club <sbmc08831@gmail.com> wrote:
> I've a small family of awk wrappers: cawk, pawk, and tawk. a clue to
> their usage:
>
> tawk () { awk -F'\t' "$@"; }
>
> "pawk" got quite a bit of use when i was at the T (at&~), since
> pipe-separated tables were widely in use there.
>
> "cawk" _never_ gets used.

You tawk the tawk, but don't get to pawk your cawk?

That's more than I want to know about the affairs of the
Stonebridge Mens Club.

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor