Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!rutgers!uwvax!oddjob!mimsy!chris From: chris@mimsy.UUCP Newsgroups: comp.unix.questions Subject: Re: prompt wars Message-ID: <5823@mimsy.UUCP> Date: Sun, 15-Mar-87 01:12:53 EST Article-I.D.: mimsy.5823 Posted: Sun Mar 15 01:12:53 1987 Date-Received: Sun, 15-Mar-87 13:37:32 EST References: <1480@umd5> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 23 Summary: sed beats awk; precomputation; no shell scripts In article <1480@umd5> zben@umd5 (Ben Cranston) writes: > alias set_prompt 'set prompt="`hnm1`[\\!] `dirs|cdt2` % "' >in "~/bin/hnm1": > #! /bin/sh > # output user-friendly head of host name > > hostname | awk -F. '{ print $1 }' Instead of using a shell script and awk, it is much faster to do this: set hostname=`hostname | sed -e 's/\..*//'` alias set_prompt 'set prompt="${hostname}[\\!] `dirs|cdt2` % "' Likewise, using `sed' to change `/usr/spool/news/comp/unix/questions' to `...unix/questions' is also faster, and if done in an alias rather than in a shell script, should be as fast as the C program Ben wrote. The sed commands to do this are left as an exercise to the reader. :-) -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7690) UUCP: seismo!mimsy!chris ARPA/CSNet: chris@mimsy.umd.edu