* [9fans] walk @ 2003-07-25 6:36 pac 2003-07-25 13:59 ` Dan Cross 0 siblings, 1 reply; 9+ messages in thread From: pac @ 2003-07-25 6:36 UTC (permalink / raw) To: 9fans walk script has been posted once, I grabbed it from the web and it is available here: ftp://ftp.gli.cas.cz/gli/cejchan/neXt/rc/walk PS: Dan Cross also has walk.c and sor.c (mentioned on the list earlier) -- Dan, please, could you share them? ++pac. --- Odchozí zpráva neobsahuje viry. Zkontrolováno antivirovým systémem AVG (http://www.grisoft.cz). Verze: 6.0.502 / Virová báze: 300 - datum vydání: 18.7.2003 ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [9fans] walk 2003-07-25 6:36 [9fans] walk pac @ 2003-07-25 13:59 ` Dan Cross 2003-07-25 14:07 ` Fco.J.Ballesteros 2003-07-25 14:16 ` [9fans] walk Charles Forsyth 0 siblings, 2 replies; 9+ messages in thread From: Dan Cross @ 2003-07-25 13:59 UTC (permalink / raw) To: 9fans [-- Attachment #1: Type: text/plain, Size: 555 bytes --] > Dan Cross also has walk.c and sor.c (mentioned on the list earlier) -- Dan, > please, could you share them? Sure. I'll include them in this email. Note, however, that sor is an rc script, not a C program. Here are some pointers to my original posts on the subject, as well. These are mainly useful as an explanation of my position and for the examples of find idioms rendered in walk/sor. https://lists.cse.psu.edu/archives/9fans/2002-October/020820.html https://lists.cse.psu.edu/archives/9fans/2002-October/020822.html - Dan C. [-- Attachment #2: Type: text/plain, Size: 2336 bytes --] /* * Walk a directory tree, in the style of du(1), * but with some additional flourishes. * * Dan Cross <cross@math.psu.edu> */ #include <u.h> #include <libc.h> static int mkdepth(int); static char *mkname(char *, int *, char *, char *); static void walk(char *, int, int); static void walkname(char *, int, int); char *fmt; void main(int argc, char *argv[]) { char *dir; int depth; Dir *d; dir = "."; fmt = "%s\n"; depth = -1; ARGBEGIN { case 'd': depth = atoi(ARGF()); break; case 'q': quotefmtinstall(); doquote = needsrcquote; fmt = "%q\n"; break; }ARGEND if (argc == 0) walkname(".", depth, 1); else { for (dir = *argv; dir; dir = *++argv) { if ((d = dirstat(dir)) == nil) { fprint(2, "dirstat %s: %r\n", dir); continue; } walkname(dir, depth, d->mode & DMDIR); free(d); } } exits(0); } static void walkname(char *dirname, int depth, int isdir) { int fd; if (strcmp(dirname, ".") != 0 && strcmp(dirname, "..") != 0) print(fmt, dirname); if (isdir) { fd = open(dirname, OREAD); if (fd < 0) { fprint(2, "open %s: %r\n", dirname); return; } walk(dirname, fd, depth); close(fd); } } static char * mkname(char *name, int *l, char *basename, char *filename) { char *nname; int t; t = strlen(basename) + 1 + strlen(filename) + 1; if (*l == 0 || name == nil) { *l = t; name = malloc(t); if (name == nil) sysfatal("malloc %d: %r\n", l); } else if (*l < t) { nname = realloc(name, t); if (nname == nil) { free(name); sysfatal("malloc %d: %r\n", l); } *l = t; name = nname; } snprint(name, t, "%s/%s", basename, filename); cleanname(name); return(name); } static int mkdepth(int depth) { return((depth == -1) ? depth : depth - 1); } static void walk(char *dirname, int fd, int depth) { Dir *dir, *dp; char *name, *nname; int i, l, n, t; if (depth == 0) return; l = 0; name = nil; n = dirreadall(fd, &dir); for (dp = dir, i = 0; i < n; dp++, i++) { if (strcmp(dp->name, ".") == 0 || strcmp(dp->name, "..") == 0) continue; name = mkname(name, &l, dirname, dp->name); walkname(name, mkdepth(depth), dp->mode & DMDIR); } free(dir); if (name != nil) free(name); } [-- Attachment #3: Type: text/plain, Size: 193 bytes --] #!/bin/rc rfork e fn runtests { file=$1; shift while (! ~ $#* 0 && ! eval $1 ''''^$file^'''') shift if (! ~ $#* 0) echo $file } while (file = `{read}) { runtests $file $* } ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [9fans] walk 2003-07-25 13:59 ` Dan Cross @ 2003-07-25 14:07 ` Fco.J.Ballesteros 2003-07-29 17:40 ` [9fans] VMWare workstation-4.0? Ishwar Rattan 2003-07-25 14:16 ` [9fans] walk Charles Forsyth 1 sibling, 1 reply; 9+ messages in thread From: Fco.J.Ballesteros @ 2003-07-25 14:07 UTC (permalink / raw) To: 9fans there's also this single `walk' script that evaluates arbitrary expressions on files, like in ;; walk . '~ $f *.c && test -r $f && cp $f /tmp' its idea is simply to set $f to the file name and evaluate the command for each file found in the tree. Works fine enough so I didn't bother to replace it. #!/bin/rc rfork e if (~ $#* 0) { echo 'usage: walk file [cmd...]' >[1=2] exit usage } file=$1 shift if (~ $#* 0) cmd='echo $f' if not cmd=$* cd `{basename -d $file} exec du -a $file | awk '{print $2}' | while (f=`{read}) { eval $cmd } ^ permalink raw reply [flat|nested] 9+ messages in thread
* [9fans] VMWare workstation-4.0? 2003-07-25 14:07 ` Fco.J.Ballesteros @ 2003-07-29 17:40 ` Ishwar Rattan 2003-07-29 18:26 ` andrey mirtchovski 0 siblings, 1 reply; 9+ messages in thread From: Ishwar Rattan @ 2003-07-29 17:40 UTC (permalink / raw) To: 9fans Is there any 'howo-to' for installing a cpu/auth server on this simulated machine? -ishwar ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [9fans] VMWare workstation-4.0? 2003-07-29 17:40 ` [9fans] VMWare workstation-4.0? Ishwar Rattan @ 2003-07-29 18:26 ` andrey mirtchovski 0 siblings, 0 replies; 9+ messages in thread From: andrey mirtchovski @ 2003-07-29 18:26 UTC (permalink / raw) To: 9fans On Tue, 29 Jul 2003, Ishwar Rattan wrote: > > Is there any 'howo-to' for installing a cpu/auth > server on this simulated machine? > you can make an auth/cpu/kfs server the same way as you would with a non-vmware machine. the instructions are in the wiki. (unless there's a brand new image for 4.0, which differs significantly from the previous one found on the plan9 web page) andrey ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [9fans] walk 2003-07-25 13:59 ` Dan Cross 2003-07-25 14:07 ` Fco.J.Ballesteros @ 2003-07-25 14:16 ` Charles Forsyth 2003-07-25 15:31 ` Dan Cross 1 sibling, 1 reply; 9+ messages in thread From: Charles Forsyth @ 2003-07-25 14:16 UTC (permalink / raw) To: 9fans >> n = dirreadall(fd, &dir); >> for (dp = dir, i = 0; i < n; dp++, i++) { >> if (strcmp(dp->name, ".") == 0 || strcmp(dp->name, "..") == 0) >> continue; you should not need to eliminate . or .. when reading a directory ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [9fans] walk 2003-07-25 14:16 ` [9fans] walk Charles Forsyth @ 2003-07-25 15:31 ` Dan Cross 0 siblings, 0 replies; 9+ messages in thread From: Dan Cross @ 2003-07-25 15:31 UTC (permalink / raw) To: 9fans > >> n = dirreadall(fd, &dir); > >> for (dp = dir, i = 0; i < n; dp++, i++) { > >> if (strcmp(dp->name, ".") == 0 || strcmp(dp->name, "..") == 0) > >> continue; > > you should not need to eliminate . or .. when reading a directory Good to know. I note, however, that du also explicitly ignores them. - Dan C. ^ permalink raw reply [flat|nested] 9+ messages in thread
* [9fans] walk @ 2003-07-24 9:03 pac 2003-07-24 9:21 ` boyd, rounin 0 siblings, 1 reply; 9+ messages in thread From: pac @ 2003-07-24 9:03 UTC (permalink / raw) To: 9fans hi! walk does not work as expected, why? term% grep -n aint *.idx 14: Maintained-At: term% walk ./ grep -n aint *.idx grep: can't open AAAAA.idx: 'AAAAA.idx' directory entry not found grep: can't open AAAAA.idx: 'AAAAA.idx' directory entry not found grep: can't open AAAAA.idx: 'AAAAA.idx' directory entry not found term% grep: can't open AAAAA.idx: 'AAAAA.idx' directory entry not found etc..... i) it does not report the match, and ii) replaces *.idx by the name of the first found idx file could someone put their hands on it? or tell me where i'm wrong? thanks, ++pac. --- Odchozí zpráva neobsahuje viry. Zkontrolováno antivirovým systémem AVG (http://www.grisoft.cz). Verze: 6.0.502 / Virová báze: 300 - datum vydání: 18.7.2003 ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [9fans] walk 2003-07-24 9:03 pac @ 2003-07-24 9:21 ` boyd, rounin 0 siblings, 0 replies; 9+ messages in thread From: boyd, rounin @ 2003-07-24 9:21 UTC (permalink / raw) To: 9fans > term% walk ./ grep -n aint *.idx the *.idx get expanded immediately and that file doesn't exist in the directory walk has chdir'd to, which it looks like it's doing. i can even find any doc for walk, nor the source. but it looks like: walk dir command [ args ... ] and it uses chdir. ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2003-07-29 18:26 UTC | newest] Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2003-07-25 6:36 [9fans] walk pac 2003-07-25 13:59 ` Dan Cross 2003-07-25 14:07 ` Fco.J.Ballesteros 2003-07-29 17:40 ` [9fans] VMWare workstation-4.0? Ishwar Rattan 2003-07-29 18:26 ` andrey mirtchovski 2003-07-25 14:16 ` [9fans] walk Charles Forsyth 2003-07-25 15:31 ` Dan Cross -- strict thread matches above, loose matches on Subject: below -- 2003-07-24 9:03 pac 2003-07-24 9:21 ` boyd, rounin
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).