Path: utzoo!attcan!uunet!mq!alan From: alan@mq.com (Alan H. Mintz) Newsgroups: comp.unix.shell Subject: Stupid sed question Keywords: sed XENIX Message-ID: <118@mq.com> Date: 26 Oct 90 22:29:44 GMT Organization: Micro-Quick Systems, Inc. Lines: 44 (Hmmm. Hard to tell if this is the right group nowadays :) I'm trying to write a script to edit the /etc/ttytype file under XENIX. The idea is to search the file for the line for a given port and alter the terminal type associated with it. The ttytype file consists of lines like: wy60ak ttya1 svt1210 ttya2 ansi ttya3 The separator between the fields is a tab character (\011, 0x09). So, ********************* : # Edit script tty='ttya1' ttytype='vt100n' line=`fgrep $tty /etc/ttytype` cat /etc/ttytype | sed "s/$line/$ttytype $tty/" >tempfile # This is a tab -----------^^^^^^ if [ $? -eq 0 ] then mv tempfile /etc/ttytype fi *********************** This works great, if the file does not contain another terminal that starts with ttya1 (like ttya10): ansi ttya1 ansi ttya10 In this case, sed barfs with "command" garbled. What am I missing here ? I understand that the problem has to do with sed matching more than one line, but why doesn't it just (incorrectly) screw up both lines ? -- < Alan H. Mintz | Voice +1 714 980 1034 > < Micro-Quick Systems, Inc. | FAX +1 714 944 3995 > < 10384 Hillside Road | uucp: ...!uunet!mq!alan > < Alta Loma, CA 91701 USA | Internet: alan@MQ.COM >