jay@hqda-ai.ARPA (Jay Hiser) (06/27/88)
I'm responsible for 3 CCI 6/32s that run SysV (CCI's rel. 2.22). I'm looking for replacements for some of the utils that I'm used to with BSD. head: the opposite of 'tail'. Shouldn't be hard to implement this in c, but I don't want to reinvent the wheel. Thought this was part of 'std' unix, but its not in my sys's docs. yes: pipe the output to some other program that expects 'y' or 'n'. I've got a file full of 'y\n' that essentially duplicates yes's function, but it doesn't seem as neat as yes. nroff: I realize that this has been unbundled (dwb?) from SysV. I still need to format man pages. Our OA sys can handle virtually all my formatting needs, except for nroff -man. Maybe this could be a GNU application some day? Anybody have an alternate source for this useful stuff? Thanks,
gwyn@brl-smoke.ARPA (Doug Gwyn ) (06/27/88)
In article <6007@hqda-ai.ARPA> jay@hqda-ai.ARPA (Jay Hiser) writes: >head: the opposite of 'tail'. if [ $# -eq 0 ] then n=10 else case $1 in [0-9]*) n=$1; shift;; *) n=10;; esac fi exec sed -e ${n}q $*
lkb@theceg.UUCP (Lawrence Keith Blische) (06/28/88)
From article <8171@brl-smoke.ARPA>, by gwyn@brl-smoke.ARPA (Doug Gwyn ): > In article <6007@hqda-ai.ARPA> jay@hqda-ai.ARPA (Jay Hiser) writes: >>head: the opposite of 'tail'. > > if [ $# -eq 0 ] > then n=10 > else case $1 in > [0-9]*) n=$1; shift;; > *) n=10;; > esac > fi > exec sed -e ${n}q $* I don't want to start the "whose's head is best" :-) war but the following version seems to better adhere to the BSD SYNOPSIS given in my Berkeley (4.3) doc for head(1): head [-count] [file ...] It also overcomes a descrepency between my SysV sed(1) man page (which indicates that sed takes multiple input files) and reality (which says it dosen't :-( ). : Bourne Shell Script if [ $# -eq 0 ] then sed 10q else case $1 in -[0-9]*) n="`echo $1|cut -c2-`" shift;; *) n="10";; esac for file in $* do sed ${n}q $file done fi ---------------------------------------------------------------------- Larry Blische ...!cp1!sarin\ The Computer Engineering Group, Inc. !wb3ffv!theceg!lkb +1 301 282 5876 (9-5 ET) ...!aplcen/
leo@philmds.UUCP (Leo de Wit) (06/29/88)
In article <8171@brl-smoke.ARPA> gwyn@brl.arpa (Doug Gwyn (VLD/VMB) <gwyn>) writes: >In article <6007@hqda-ai.ARPA> jay@hqda-ai.ARPA (Jay Hiser) writes: >>head: the opposite of 'tail'. > >if [ $# -eq 0 ] >then n=10 >else case $1 in > [0-9]*) n=$1; shift;; > *) n=10;; > esac >fi >exec sed -e ${n}q $* I like that. He (Jay) also writes: >yes: pipe the output to some other program that expects 'y' or 'n'. #!/bin/sh # yes - be repetitively affirmative case $# in 0) set y;; esac exec sed ' : again p b again' <<EOT $1 EOT Now there is still nroff to take care of. Anybody feels an urge to add his "one"-liner, using sed 8-) ? Leo.
gwyn@brl-smoke.ARPA (Doug Gwyn ) (07/01/88)
In article <366@theceg.UUCP> lkb@theceg.UUCP (Lawrence Keith Blische) writes: > head [-count] [file ...] But that's a violation of the command syntax standard (if count > 9). Thus my version omits the -. It does make it hard to deal with files whose names start with a digit, and is imperfect in other ways. Actually I always type the direct "sed" command myself: program | sed 23q