From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f678f,f1d797a60a92e799 X-Google-Attributes: gidf678f,public From: Doug Chapman USG Subject: Re: Awk Date: 1998/11/20 Message-ID: <3655C507.A24DEC49@just.post.to.news>#1/1 X-Deja-AN: 414322997 Content-Transfer-Encoding: 7bit References: <733tj8$meo$1@hdxf08.telecom.ptt.nl> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii Organization: CTG Mime-Version: 1.0 Newsgroups: comp.unix.osf.misc GJH wrote: > > for example a string : 'thisisastring' where I want the first four > characters : this. > Sed works nicely: echo thisisastring | sed 's/\(....\).*/\1/' The \(....\) part means save the first 4 characters (due to the for . ) The .* just matches the rest of the string The \1 means write out what was matched by what was in the first set of \( \) - Doug