9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Alexander Kapshuk <alexander.kapshuk@gmail.com>
To: 9fans <9fans@9fans.net>
Subject: Re: [9fans] Help with a sam cleanup script
Date: Wed, 21 Jul 2021 12:52:20 +0300	[thread overview]
Message-ID: <CAJ1xhMU=CrV4Bk=iVscW0gFAEJDwrwJV44WUhg1m5VmW0UOXhQ@mail.gmail.com> (raw)
In-Reply-To: <16268590350.573C31.33295@composer.9fans.topicbox.com>

On Wed, Jul 21, 2021 at 12:18 PM <revcomninos@gmail.com> wrote:
>
> In ed I have a cleanup script which I can apply to several files at once. The script removes things like blank lines and spaces between words. To run it on a file or multiple files, I type this command:
> ed [name of file(s)] < cleanup-script
> I converted all the regular expressions in the file into sam regex format and tried the same, but to no avail.  Here is a list of some of the commands:
>
> .x s/\*//g
> ,x/^ +/s///
> ,x/ +$/s///
> ,x/  +/s// /
> ,x/^$\n/d
> ,x/‘‘|’’/s//"/
> ,x/“|”/s//"/
> ,x/‘|’/s//"/
> ,x/^ +/s///
> ,x/ +$/s///
> ,x/  +/s// /
> ,x/^$\n/d
> ,x/‘‘|’’/s//"/
> ,x/“|”/s//"/
> ,x/‘|’/s//"/
> ,x/teh/c/the/
> wq
>
> I am not even sure sam can do this, but if it can, I would appreciate some guidance on how to do it.
>
>
> 9fans / 9fans / see discussions + participants + delivery options Permalink

As far as having sam commands apply to multiple files, the X command is there:
sam(1):
X/regexp/ command
               For each file whose menu entry matches the regular
expression, make that the current file and run the command.
               If the expression is omitted, the command is run in every file.

Given these target files:
grep . file[12]
file1:line1
file2:line2

And a file that contains some sam commands:
cat cmd
X ,p
q

The following output is printed:
sam -d file[12] <cmd
 -. file1
line1
 -  file2
line2

------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/T10b1d559ae7d981e-Mbddcbb3fb3e41229d32d0ca7
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

  parent reply	other threads:[~2021-07-21  9:53 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-21  9:17 revcomninos
2021-07-21  9:24 ` Rodrigo G. López
2021-07-21  9:24 ` Rob Pike
2021-07-21  9:28 ` umbraticus
2021-07-21 10:02   ` revcomninos
2021-07-21 10:19     ` umbraticus
2021-07-21 10:49       ` revcomninos
2021-07-21 18:36         ` revcomninos
2021-07-21 18:47           ` revcomninos
2021-07-21 20:40             ` Silas McCroskey
2021-07-21 20:41               ` Silas McCroskey
2021-07-22  9:51                 ` revcomninos
2021-07-21  9:52 ` Alexander Kapshuk [this message]
2021-07-21 10:09   ` umbraticus
2021-07-26 14:17     ` revcomninos
2021-07-26 21:07       ` ori
2021-07-27  3:07         ` Mark van Atten
2021-07-27  6:32           ` revcomninos
2021-07-27  6:33           ` revcomninos
2021-07-27 13:23           ` Iruatã Souza
2021-07-27 13:28             ` Mark van Atten
2021-07-27 13:39             ` kvik
2021-07-27 14:14               ` Jacob Moody
2021-07-28 11:25               ` Iruatã Souza
2021-08-03 15:04                 ` fwrm via 9fans
2021-08-03 16:29                   ` fwrm via 9fans
2021-08-03 16:30             ` revcomninos
2021-08-03 18:03               ` Charles Forsyth

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAJ1xhMU=CrV4Bk=iVscW0gFAEJDwrwJV44WUhg1m5VmW0UOXhQ@mail.gmail.com' \
    --to=alexander.kapshuk@gmail.com \
    --cc=9fans@9fans.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).