9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] ls -R
@ 2001-08-08 10:45 rog
  2001-08-08 17:08 ` [9fans] Sam question gene garbutt
  0 siblings, 1 reply; 17+ messages in thread
From: rog @ 2001-08-08 10:45 UTC (permalink / raw)
  To: 9fans

[-- Attachment #1: Type: text/plain, Size: 874 bytes --]

sorry, boyd's response wasn't enormously helpful.

as far as i know the only plan 9 utility around that traverses the
file tree is du(1).

personally, i have a little rc script in my bin called find
(attached), which does almost all of what i used to use find for under
unix, i.e.  find files with a particular name.

e.g.
	find . '\.c$'
to find all c source files.

i've also got a little version of xargs (also attached) that reads
filenames from stdin and occasionally executes a command with those as
arguments, which is useful when grepping in hierarchies where the list
of files will be larger than execv will tolerate (plus you start
getting results sooner).  luckily newlines are illegal in plan 9 names
AFAIK so it's not vulnerable to the same problems as the unix xargs.

so ls -lR becomes:

	find . . | xargs ls -l

  cheers,
    rog.


[-- Attachment #2: find --]
[-- Type: text/plain, Size: 181 bytes --]

#!/bin/rc
if (~ $#* 1 0) {
	echo 'usage: find <dir>... <re>' >[1=2]
	exit usage
}
a=()
while (! ~ $#* 1) {
	a=($a $1)
	shift
}
du -a $a | sed 's/^[^ 	]*[ 	]//' | grep $1

[-- Attachment #3: xargs.c --]
[-- Type: text/plain, Size: 1647 bytes --]

#include <u.h>
#include <libc.h>
#include <bio.h>

char *makeline(void);

#define NUMARGS 470
#define MAXSIZE 5000

void run(char **cmd);
Biobuf stdin;
int main(int argc, char **argv)
{
	char **cmd;
	int i, n, m, size;
	if (argc < 2) {
		fprint(2, "Usage: xargs [cmd args...]\n");
		exits("bad usage");
	}
	if (Binit(&stdin, 0, OREAD) == -1) {
		fprint(2, "couldn't init stdin\n");
		exits("error");
	}
	cmd = malloc((argc - 1 + NUMARGS + 1) * sizeof(char *));
	n = 0;
	for (i = 1; i < argc; i++) {
		cmd[n++] = argv[i];
	}

	for (;;) {
		int eof = 0;;
		size = 0;
		for (m = 0; m < NUMARGS && size < MAXSIZE; m++) {
			if ((cmd[n + m] = makeline()) == 0) {
				eof = 1;
				break;
			}
			size += strlen(cmd[n + m]);
		}
		cmd[n + m] = 0;
		if (m > 0)
			run(cmd);
		for (i = 0; i < m; i++) {
			free(cmd[n+i]);
		}
		if (eof)
			break;
	}
	return 0;
}

int pwait(void)
{
	Waitmsg msg;
	if (wait(&msg) == -1)
		return -1;
	return atoi(msg.pid);
}

void run(char **cmd)
{
	char buf[256];
	int npid, pid = fork();
	if (pid == -1) {
		perror("couldn't fork");
		exits("no forkage");
	}
	if (pid == 0) {
		if (cmd[0][0] != '/' && strncmp(cmd[0], "./", 2)) {
			sprint(buf, "/bin/%s", cmd[0]);
			exec(buf, cmd);
		} else {
			exec(cmd[0], cmd);
		}
		perror(cmd[0]);
		exits("no exec");
	}
	while ((npid = pwait()) != pid && npid != -1)
		;
}

char *makeline(void)
{
	char *ln, *ret;
	int len;
	if ((ln = Brdline(&stdin, '\n')) == 0) {
		return 0;
	}
	len = Blinelen(&stdin);
	ret = malloc(len + 1);
	memcpy(ret, ln, len);
	ret[len-1] = '\0';
	return ret;
}

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [9fans] Sam question
  2001-08-08 10:45 [9fans] ls -R rog
@ 2001-08-08 17:08 ` gene garbutt
  2001-08-14  9:44   ` Douglas A. Gwyn
  0 siblings, 1 reply; 17+ messages in thread
From: gene garbutt @ 2001-08-08 17:08 UTC (permalink / raw)
  To: 9fans

I am a sam newbie and have a quick question for the experts...

How would I remove backspaces from a file? Or search for a backspace in a
file?

I haven't figured out how to get the backspace character in sam command. I
can snarf a backspace from the target file and do it that way, but I assume
there must be a better way?

Thanks,
Gene Garbutt
ggarbutt@earthlink.net




^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [9fans] Sam question
  2001-08-08 17:08 ` [9fans] Sam question gene garbutt
@ 2001-08-14  9:44   ` Douglas A. Gwyn
  2001-08-14 17:02     ` [9fans] h is for help in tp Rick Hohensee
  2001-08-16 21:07     ` [9fans] Sam question Boyd Roberts
  0 siblings, 2 replies; 17+ messages in thread
From: Douglas A. Gwyn @ 2001-08-14  9:44 UTC (permalink / raw)
  To: 9fans

gene garbutt wrote:
> I haven't figured out how to get the backspace character in sam command. I
> can snarf a backspace from the target file and do it that way, but I assume
> there must be a better way?

Not so far as I know.


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [9fans] h is for help in tp
  2001-08-14  9:44   ` Douglas A. Gwyn
@ 2001-08-14 17:02     ` Rick Hohensee
  2001-08-16 21:07     ` [9fans] Sam question Boyd Roberts
  1 sibling, 0 replies; 17+ messages in thread
From: Rick Hohensee @ 2001-08-14 17:02 UTC (permalink / raw)
  To: 9fans

I just have the command language of sam in cLIeNUX, since I don't use X. I
also call sam tp for "text processor". In view of someone whining about
the user interface, allow me to re-post my cheatsheet. In cLIeNUX tp
(sam) this comes up when you hit h. If there's further interest I'll post
the code to do that, which is trivial.


h

____________________________________________________________________________
cLIeNUX sam/tp text processing language cheatsheet
cheatsheet markup...
  refNAME  `default'  "virtual"  /delimited/  0_or_more...  <variable>

syntax operators                (in commands, not patterns or strings)
  delimiter                     any punctuation, paired or with EOL
  next character is literal     \

text location operators         (address elements)
  linefeed (unix newline)       \n
  "empty line" at End Of File   $
  current text segment          .
  MARKed text segment           '
  scanning DIRection            - or `+'
  Line Number                   <digits>
  Character Number              #<digits>
  match scan PATtern            /regular expression, \n allowed/
  OFFset                        <DIR>LN or CN or PAT or `1'
  HALF address                  <LN or CN or PAT or MARK or `.'><OFF...>
  full ADDRess                  <HALF>,<HALF>    just  ,  is whole buffer

text inputs
  INTERactive                   accept typed text up to . alone on line
  Whole Match Backreference     &
  SUBmatch backreference        \<digit>    nth match ()-delimited in PAT
  LITeral string                /literal text and|or WMB... and|or SUB.../
  INPUT                         LIT or INTER

commands and thier PHRASE syntaxes, some multi-buffer phrases omitted
  <ADDR>a<INPUT>                _append_ INPUT after address
        b<buffer>               make buffer the current buffer
  <ADDR>c<INPUT>                _clobber_ address with INPUT
  <ADDR>d                       _delete_ addressed range of text
        e<file>                 _edit_ file, make file current buffer
        f<name>                 rename current buffer
  <ADDR>g<PAT> PHRASE           do PHRASE _if_ PAT matches in ADDR
        h                       You're soaking in it.
  <ADDR>i<INPUT>                _insert_ INPUT before address
  <ADDR>k                       mark address for reference as '
  <ADDR>m<ADDR>                 move, not copy
        n                       list buffers
  <ADDR>p                       _print_ to stdout. usual default command.
        q                       _quit_. Always works the second time.
  <ADDR>r<file>                 _read_ file into buffer after ADDR
  <ADDR>s<PAT><LIT>             use <ADDR>x<PAT>c<INPUT> instead
  <ADDR>t<ADDR>                 copy
        u                       undo. Unlimited, but one-way.
  <ADDR>v<PAT> PHRASE           do PHRASE if PAT _doesn't_ match in ADDR
  <ADDR>w<file>                 _write_ out ADDR. default is whole buffer.
  <ADDR>x<PAT> PHRASE           for each match of PAT in ADDR do PHRASE
  <ADDR>y<PAT> PHRASE           do PHRASE on text between each PAT in ADDR
............................................................................




Rick Hohensee
					www.clienux.com


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [9fans] Sam question
  2001-08-14  9:44   ` Douglas A. Gwyn
  2001-08-14 17:02     ` [9fans] h is for help in tp Rick Hohensee
@ 2001-08-16 21:07     ` Boyd Roberts
  2001-08-17  8:50       ` Douglas A. Gwyn
  2001-08-17 10:22       ` Re[2]: " Matt
  1 sibling, 2 replies; 17+ messages in thread
From: Boyd Roberts @ 2001-08-16 21:07 UTC (permalink / raw)
  To: 9fans

From: "Douglas A. Gwyn" <DAGwyn@null.net>
> > I can snarf a backspace from the target file and do it that way, but I assume
> > there must be a better way?
> 
> Not so far as I know.

yup, that's how i do it.  same deal with blowing away cr's.

anyone like to blow away tabs on any given windows app?




^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [9fans] Sam question
  2001-08-16 21:07     ` [9fans] Sam question Boyd Roberts
@ 2001-08-17  8:50       ` Douglas A. Gwyn
  2001-08-17 10:27         ` Re[2]: " Matt
  2001-08-17 12:14         ` Boyd Roberts
  2001-08-17 10:22       ` Re[2]: " Matt
  1 sibling, 2 replies; 17+ messages in thread
From: Douglas A. Gwyn @ 2001-08-17  8:50 UTC (permalink / raw)
  To: 9fans

Boyd Roberts wrote:
> anyone like to blow away tabs on any given windows app?

I carry around a utility I originally developed at Geotronics
(early 1980s) called "retab" that transforms from one set of
tabs stops to another in one pass; it can turn all tabs to an
appropriate number of spaces by specifying -o +1.  The manual
page could be improved, but here it is:

NAME
     retab - detab|entab utility

SYNOPSIS
     retab [ [ -io ] global_options ] [ -i input_options ]  [  -o
     output_options ]

DESCRIPTION
     Retab reformats text containing combinations of  spaces  and
     tabs  in accordance with user-specified input and output tab
     stops; trailing spaces and tabs are removed.  Retab is suit-
     able for use as a filter or as a stand-alone utility.

     Options following -i apply to the input text; those  follow-
     ing -o apply to the output text; all others, including those
     following -io, apply to both input and output.  Options  may
     consist  of  a filename (standard input or output used if no
     file specified) and/or tab stop specifications.   Tab  stops
     are  specified  as  a  list  of column numbers (the leftmost
     print position is column # 1)  optionally  followed  by  the
     increment  of  a  regularly-spaced  series of stops past the
     last explicitly given column number; the increment is speci-
     fied  in the form +n.  Unspecified input or output tab stops
     are assumed to be UNIX standard (equivalent to specifying  9
     +8).

EXAMPLE
          $ retab -i foo -o +5
     interprets the tab settings in file ``foo'' according to the
     standard  eight-column  spacing while printing on a terminal
     having hardware stops set in every fifth column.

SEE ALSO
     newform(1).

DIAGNOSTICS
     In case of malfunction, retab terminates with an error  mes-
     sage and returns non-zero exit status.

AUTHOR
     Douglas A. Gwyn, BRL/VLD-VMB


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re[2]: [9fans] Sam question
  2001-08-16 21:07     ` [9fans] Sam question Boyd Roberts
  2001-08-17  8:50       ` Douglas A. Gwyn
@ 2001-08-17 10:22       ` Matt
  1 sibling, 0 replies; 17+ messages in thread
From: Matt @ 2001-08-17 10:22 UTC (permalink / raw)
  To: Boyd Roberts


BR> anyone like to blow away tabs on any given windows app?
try EditPlus (very good widnows editor)

it has /t as part of it's regex armoury



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re[2]: [9fans] Sam question
  2001-08-17  8:50       ` Douglas A. Gwyn
@ 2001-08-17 10:27         ` Matt
  2001-08-17 12:14         ` Boyd Roberts
  1 sibling, 0 replies; 17+ messages in thread
From: Matt @ 2001-08-17 10:27 UTC (permalink / raw)
  To: 9fans

BR> Boyd Roberts wrote:
BR> anyone like to blow away tabs on any given windows app?

I htink one of the best utilities for windows is cygwin though if you
are stuck with no proper tools.



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [9fans] Sam question
  2001-08-17  8:50       ` Douglas A. Gwyn
  2001-08-17 10:27         ` Re[2]: " Matt
@ 2001-08-17 12:14         ` Boyd Roberts
  2001-08-17 12:35           ` Re[2]: " Matt
  2001-08-20  8:56           ` Douglas A. Gwyn
  1 sibling, 2 replies; 17+ messages in thread
From: Boyd Roberts @ 2001-08-17 12:14 UTC (permalink / raw)
  To: 9fans

From: "Douglas A. Gwyn" <DAGwyn@null.net>
> Boyd Roberts wrote:
> > anyone like to blow away tabs on any given windows app?
> 
> I carry around a utility I originally developed at Geotronics
> (early 1980s) called "retab" that transforms ...

i was hinting at the fact that tabs on windows are _special_.

ie. they move you from one field to the next.  a real bugger
    when you _want_ to type a tab in a dialog box.




^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re[2]: [9fans] Sam question
  2001-08-17 12:14         ` Boyd Roberts
@ 2001-08-17 12:35           ` Matt
  2001-08-20  8:56           ` Douglas A. Gwyn
  1 sibling, 0 replies; 17+ messages in thread
From: Matt @ 2001-08-17 12:35 UTC (permalink / raw)
  To: Boyd Roberts

BR> i was hinting at the fact that tabs on windows are _special_.

BR> ie. they move you from one field to the next.  a real bugger
BR>     when you _want_ to type a tab in a dialog box.

o i c

yes that is annoying

one example of the many braindead things

as vitanuova will tell you concernign the backspace in their Inferno
plugin

IE hard traps it to "back"



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [9fans] Sam question
  2001-08-17 12:14         ` Boyd Roberts
  2001-08-17 12:35           ` Re[2]: " Matt
@ 2001-08-20  8:56           ` Douglas A. Gwyn
  2001-08-20 11:11             ` Boyd Roberts
  2001-08-20 16:25             ` Sam Ducksworth
  1 sibling, 2 replies; 17+ messages in thread
From: Douglas A. Gwyn @ 2001-08-20  8:56 UTC (permalink / raw)
  To: 9fans

Boyd Roberts wrote:
> i was hinting at the fact that tabs on windows are _special_.
> ie. they move you from one field to the next.  a real bugger
>     when you _want_ to type a tab in a dialog box.

Ah, okay.  But when you're filling in a form under the Windows
default model, you're not supposed to be entering tab characters
into text, any more than you're supposed to be entering arrow-key
characters.  It's just an unsuitable model for your application.

I'm not saying the Windows GUI is very good, just that if you
have to deal with it, it must be on its own terms..


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [9fans] Sam question
  2001-08-20  8:56           ` Douglas A. Gwyn
@ 2001-08-20 11:11             ` Boyd Roberts
  2001-08-20 16:25             ` Sam Ducksworth
  1 sibling, 0 replies; 17+ messages in thread
From: Boyd Roberts @ 2001-08-20 11:11 UTC (permalink / raw)
  To: 9fans

> I'm not saying the Windows GUI is very good, just that if you
> have to deal with it, it must be on its own terms..

don't i know it -- <gag>.




^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [9fans] Sam question
  2001-08-20 16:25             ` Sam Ducksworth
@ 2001-08-20 15:11               ` Boyd Roberts
  2001-08-21  8:37                 ` Ozan Yigit
  0 siblings, 1 reply; 17+ messages in thread
From: Boyd Roberts @ 2001-08-20 15:11 UTC (permalink / raw)
  To: 9fans

> it will be great! the office people will love it." ;-)

it was great.  it came out of PARC and the 'office people'
loved it.  pity that xerox didn't.




^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [9fans] Sam question
  2001-08-20  8:56           ` Douglas A. Gwyn
  2001-08-20 11:11             ` Boyd Roberts
@ 2001-08-20 16:25             ` Sam Ducksworth
  2001-08-20 15:11               ` Boyd Roberts
  1 sibling, 1 reply; 17+ messages in thread
From: Sam Ducksworth @ 2001-08-20 16:25 UTC (permalink / raw)
  To: 9fans

you guys bitch and moan about tab keys and the like. just
think about the poor guy that said, "hey i got an idea a
lets find a way to interface one of our typewriters to this
thing. it will be great! the office people will love it." ;-)

--sam



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [9fans] Sam question
  2001-08-20 15:11               ` Boyd Roberts
@ 2001-08-21  8:37                 ` Ozan Yigit
  2001-08-21  9:31                   ` Boyd Roberts
  0 siblings, 1 reply; 17+ messages in thread
From: Ozan Yigit @ 2001-08-21  8:37 UTC (permalink / raw)
  To: 9fans

boyd@fr.inter.net (Boyd Roberts) writes:

> it was great.  it came out of PARC and the 'office people'
> loved it.  pity that xerox didn't.

history of ALTO reduced to a sound byte?


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [9fans] Sam question
  2001-08-21  8:37                 ` Ozan Yigit
@ 2001-08-21  9:31                   ` Boyd Roberts
  2001-08-22  2:52                     ` Donald Brownlee
  0 siblings, 1 reply; 17+ messages in thread
From: Boyd Roberts @ 2001-08-21  9:31 UTC (permalink / raw)
  To: 9fans

> history of ALTO reduced to a sound byte?

well, i wouldn't want to fill up /n/dump, but i can
see my copy of _fumbling the future_ from here.




^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [9fans] Sam question
  2001-08-21  9:31                   ` Boyd Roberts
@ 2001-08-22  2:52                     ` Donald Brownlee
  0 siblings, 0 replies; 17+ messages in thread
From: Donald Brownlee @ 2001-08-22  2:52 UTC (permalink / raw)
  To: 9fans


> 
> > history of ALTO reduced to a sound byte?
> 
> well, i wouldn't want to fill up /n/dump, but i can
> see my copy of _fumbling the future_ from here.

Too bad fumbling-the-future can't be patented.


^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2001-08-22  2:52 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-08-08 10:45 [9fans] ls -R rog
2001-08-08 17:08 ` [9fans] Sam question gene garbutt
2001-08-14  9:44   ` Douglas A. Gwyn
2001-08-14 17:02     ` [9fans] h is for help in tp Rick Hohensee
2001-08-16 21:07     ` [9fans] Sam question Boyd Roberts
2001-08-17  8:50       ` Douglas A. Gwyn
2001-08-17 10:27         ` Re[2]: " Matt
2001-08-17 12:14         ` Boyd Roberts
2001-08-17 12:35           ` Re[2]: " Matt
2001-08-20  8:56           ` Douglas A. Gwyn
2001-08-20 11:11             ` Boyd Roberts
2001-08-20 16:25             ` Sam Ducksworth
2001-08-20 15:11               ` Boyd Roberts
2001-08-21  8:37                 ` Ozan Yigit
2001-08-21  9:31                   ` Boyd Roberts
2001-08-22  2:52                     ` Donald Brownlee
2001-08-17 10:22       ` Re[2]: " Matt

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).