From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <7cf3d9b282bcf24804e48d407f86b378@coraid.com> From: erik quanstrom Date: Thu, 23 Nov 2006 08:13:25 -0500 To: 9fans@cse.psu.edu Subject: Re: [9fans] Sam scripting In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="upas-rvbzaulubetdefangykpthhadc" Topicbox-Message-UUID: e5f22866-ead1-11e9-9d60-3106f5b1d025 This is a multi-part message in MIME format. --upas-rvbzaulubetdefangykpthhadc Content-Disposition: inline Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit sure, you can use sam for scripting. one can suppress starting samterm with the -d option. though this is more like using ed in a script than sed. i attached a unix script that i use to find people in address files with records containing a '^NAME ' field, delimited by newlines. it's written for byron's rc. there's also an "ssam" out there analogous to sed. i believe this is the url: http://www.freshports.org/editors/ssam/ though i haven't checked it myself. - erik --upas-rvbzaulubetdefangykpthhadc Content-Disposition: attachment; filename=tel.sam Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit #!/usr/local/bin/rc # bugs -- case sensitive matching nl = ' ' bookdir = $home/doc/address book = () if (~ $1 -b){ shift if (~ $1 /* ./ ../) book = $1 else book = $bookdir/$1 shift } else { for (i in $bookdir/*) if (test -f $i) book = ($book $i) } if (~ $#* 0) exit 0 args = $1 shift for (i) args = $args'|'$i echo 'X:.: , x/^\n/+/(.+\n)+/ g/^NAME.*('^$args^')/ p' | \ sam -d $book >[2] /dev/null | \ sed '2,$ s/^NAME/\'$nl'&/g' --upas-rvbzaulubetdefangykpthhadc--