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: <3655CAFF.CF917D4B@just.post.to.news>#1/1 X-Deja-AN: 414333884 Content-Transfer-Encoding: 7bit References: <733tj8$meo$1@hdxf08.telecom.ptt.nl> <3655C507.A24DEC49@just.post.to.news> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii Organization: CTG Mime-Version: 1.0 Newsgroups: comp.unix.osf.misc Doug Chapman USG wrote: > > > > for example a string : 'thisisastring' where I want the first four > > characters : this. > > > > Sed works nicely: > > echo thisisastring | sed 's/\(....\).*/\1/' > Sorry to followup to my own post but I guess it can be done easily with awk: echo thisisastring | awk '{printf ("%.4s\n",$1)}' - Doug