From: "Rob Pike" <robpike@gmail.com>
To: "Fans of the OS Plan 9 from Bell Labs" <9fans@cse.psu.edu>
Subject: Re: [9fans] Non-parallel loop in Sam
Date: Thu, 7 Feb 2008 22:43:13 +1100 [thread overview]
Message-ID: <7359f0490802070343h4f425855o611ebbcb0dce147@mail.gmail.com> (raw)
In-Reply-To: <47AA38CF.5AC2EDD9@null.net>
, | tail -r
is simpler.
-rob
On Thu, Feb 7, 2008 at 8:55 PM, Douglas A. Gwyn <DAGwyn@null.net> wrote:
> > My question is, how to
> > impliment non-parallel loop/condition commands in Sam?
>
> As you noticed, it's a different model from ed, sed, etc.
> In sam, you can specify sequential edits on separate lines,
> and a collection of lines can be grouped into a single action
> by surrounding the lines with braces { }.
>
>
> > In another
> > word, how to do things, such as inverse all lines, in Sam
>
> Don't forget that you have a lot of text-oriented tools at
> your disposal in any Unix or Plan 9 environment. To
> reverse the order of lines within a file already opened by
> sam, I would simply enter the following sam commands:
> ,| nl | sort -rn
> ,x/^ +[0-9]+ /d
> (on Solaris; maybe a slight change would be needed on Plan 9).
> This would be better packaged as a shell script, using sed
> rather than sam for the final number-stripping operation.
> You could then merely invoke that script for whatever "dot"
> region is selected in sam:
> | reverse # the script name
> It is nice to build up a little collection of useful
> editing scripts. Sometimes it is useful to enter nroff
> source and pipe it through nroff for automatic formatting:
> unformatted text
> .pl 12p\"prevent spacing to end of page afterward
> .ll 2i
> .tl 'le'ctr'ri'
> .ce
> centered title
> formatted text
> unformatted text
> Highlight (set dot to) all but the "unformatted text" and
> enter the same command
> | nroff -Tlp
> (on Solaris; for Plan 9 -Tlp is probably different). The
> -ms or other nroff macro package could be used, as desired.
>
next prev parent reply other threads:[~2008-02-07 11:43 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-06 16:57 Hongzheng Wang
2008-02-07 9:55 ` Douglas A. Gwyn
2008-02-07 11:33 ` Hongzheng Wang
2008-02-07 11:38 ` sqweek
2008-02-07 11:42 ` y i y u s
2008-02-07 11:43 ` Rob Pike [this message]
2008-02-07 12:37 ` Hongzheng Wang
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=7359f0490802070343h4f425855o611ebbcb0dce147@mail.gmail.com \
--to=robpike@gmail.com \
--cc=9fans@cse.psu.edu \
/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).