From: Russ Cox <russcox@gmail.com>
To: 9fans <9fans@cse.psu.edu>
Subject: [9fans] some shell scripts
Date: Wed, 13 Oct 2004 18:38:15 -0400 [thread overview]
Message-ID: <ee9e417a041013153822acb741@mail.gmail.com> (raw)
First, a nice little clock for acme.
I "ported" this over to the Unix acme today
and realized I'd never posted it. The ... around
the time is so that when you Sort it ends up at the top.
t23=; cat plan9/bin/rc/Clock
#!/bin/rc
cd /mnt/acme/new
while (date | sed 's/.* (..:..).*/name ...\1.../' >ctl)
sleep 60
t23=; cat bin/Clock
#!/usr/local/plan9/bin/rc
n=`{9p read acme/new/ctl}
echo $n
n=$n(1)
while (date | 9sed 's/.* (..:..).*/name ...\1.../' | 9p write acme/$n/ctl)
sleep 60
t23=;
Second, inspired by reading about Nemo's tags,
I realized that, on Unix, I use locate | grep way too much
and I'm sick of typing really long path names.
This script L prints all names on the system
matching the argument except that / can expand
to any number of elements. So:
t23=; L plan9/acme
/usr/local/plan9/acid/acme
/usr/local/plan9/bin/acme
/usr/local/plan9/src/cmd/acme
t23=; L plan9/download.c
/usr/local/plan9/src/cmd/postscript/download/download.c
t23=;
Plan 9 users will have to substitute locate with something
like du -a / in cron to update /tmp/locate-slash.
t23=; cat bin/L
#!/usr/local/plan9/bin/rc
TMP=/tmp
if(~ $#* 0){
echo 'usage: L pth ...' >[1=2]
exit usage
}
fn dogrep {
if(~ $#* 1)
grep /$1
if not{
x=$1
shift
grep /$x | dogrep $*
}
}
# it is noticeably faster (.09s vs .55s) to just
# save the raw locate database somewhere [sic]
if(! test -f $TMP/locate-slash
|| test `{mtime $TMP/locate-slash | awk '{print $1}'} -lt `{hoc -e
`{$PLAN9/bin/date -n}^-86400})
locate / >$TMP/locate-slash
nl='
'
for(i){
ifs=$nl { pattern=`{echo $i | 9sed 's;\*;[^/]*;g; s;/;/(.*/)?;g;
s;^;(.*/)?;; s;$;$;'} }
egrep $pattern $TMP/locate-slash
}
t23=;
and then the obvious next step is BL:
t23=; cat bin/BL
#!/usr/local/plan9/bin/rc
B `{L $*}
t23=;
next reply other threads:[~2004-10-13 22:38 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-10-13 22:38 Russ Cox [this message]
2004-10-14 5:29 ` Martin C.Atkins
2004-10-14 6:50 ` geoff
2004-10-14 9:56 ` Martin C.Atkins
2004-10-14 15:29 ` Nigel Roles
2004-10-15 0:25 ` geoff
2004-10-15 0:28 ` Russ Cox
2004-10-15 0:38 ` geoff
2004-10-14 9:22 ` Fco. J. Ballesteros
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=ee9e417a041013153822acb741@mail.gmail.com \
--to=russcox@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).